On fuzzification tools and fuzzy arithmetics

library(FuzzySTs)
#> Loading required package: FuzzyNumbers
#> Loading required package: polynom
#> 
#> Attaching package: 'FuzzySTs'
#> The following object is masked from 'package:FuzzyNumbers':
#> 
#>     distance

is.alphacuts(): Verifies if a matrix is set of left and right alpha-cuts

FuzzySTs::is.alphacut() verifies if a given matrix can be a matrix of numerical alpha-cuts. It is then verified if the considered matrix has the following requirements: it should be composed by 2 vectors in columns with no missing values, for which the lengthes of both vectors are equal. The first vector should be increasing and named “L” as left, and the second one should be decreasing and named “U” as upper. The last value of the first vector should be less than the first value of the second vector.

mat <- matrix(c(1,2,3,7,6,5), ncol = 2) 
is.alphacuts(mat)
#> [1] TRUE

nbreakpoints(): Calculates the number of breakpoints of a numerical matrix of alpha-cuts

For a given fuzzy number expressed by its numerical alpha-cuts such that is.alphacuts = TRUE, the function FuzzySTs::nbreakpoints() calculates the number of breakpoints chosen to numerically construct these alpha-cuts. In other terms, it is the number of sample points on which the membership functions are evaluated.

X <- TrapezoidalFuzzyNumber(1,2,3,4)
alpha.X <- alphacut(X, seq(0,1,0.01)) 
nbreakpoints(alpha.X)
#> [1] 100

GaussianFuzzyNumber(): Creates a Gaussian fuzzy number

FuzzySTs::GaussianFuzzyNumber() creates a Gaussian fuzzy number from the class of Gaussian fuzzy numbers. This number is given by its numerical alpha-cuts such that is.alphacuts = TRUE. The smoothness of the constructed curve are defined by the step, the margin and the precision fixed by default to 0.01, [3 * sigma; 3 * sigma] and 4.

GFN <- GaussianFuzzyNumber(mean = 0, sigma = 1, alphacuts = TRUE, plot=TRUE)

is.alphacuts(GFN)
#> [1] TRUE

GaussianBellFuzzyNumber(): Creates a Gaussian two-sided bell fuzzy number

FuzzySTs::GaussianBellFuzzyNumber() creates a two-sided Gaussian Bell fuzzy number from the class of Gaussian Bell fuzzy numbers. The constructed curve is a combination of two Gaussian curves. The smoothness of the constructed curve are defined by the step, the margin and the precision fixed by default to 0.01, [3 * left.sigma; 3 * right.sigma] and 4.

GBFN <- GaussianBellFuzzyNumber(left.mean = -1, left.sigma = 1, right.mean = 2, right.sigma = 1, alphacuts = TRUE, plot=TRUE)

is.alphacuts(GBFN)
#> [1] TRUE

Fuzzy.Difference(): Calculates the difference between two fuzzy numbers

FuzzySTs::Fuzzy.Difference() calculates the difference between two trapezoidal fuzzy numbers with respect to the extension principle. In case the fuzzy numbers are not trapezoidal, and written by their numerical alpha-cuts, the function constructs a trapezoidal approximation composed by the minimum and maximum values of the left and the right alpha-cuts of the fuzzy number.

X <- TrapezoidalFuzzyNumber(5,6,7,8)
Y <- TrapezoidalFuzzyNumber(1,2,3,4)
Fuzzy.Difference(X,Y)
#> Trapezoidal fuzzy number with:
#>    support=[2,6],
#>       core=[3,5].

Fuzzy.Square(): Calculates numerically the square of a fuzzy number

FuzzySTs::Fuzzy.Square() calculates numerically the square of a fuzzy number with respect to the extension principle. The considered input fuzzy number is supposed to be trapezoidal or triangular. However, if a fuzzy number of some other types is introduced by its numerical alpha-cuts, a trapezoidal approximative fuzzy number is constructed by considering the minimum and maximum values of the left and the right alpha-cuts of the fuzzy number. The calculations are based on resolving second order polynoms.

X <- TrapezoidalFuzzyNumber(1,2,3,4)
Fuzzy.Square(X, plot=TRUE)

#>           L       U
#> 0.00 1.0000 16.0000
#> 0.01 1.0201 15.9201
#> 0.02 1.0404 15.8404
#> 0.03 1.0609 15.7609
#> 0.04 1.0816 15.6816
#> 0.05 1.1025 15.6025
#> 0.06 1.1236 15.5236
#> 0.07 1.1449 15.4449
#> 0.08 1.1664 15.3664
#> 0.09 1.1881 15.2881
#> 0.10 1.2100 15.2100
#> 0.11 1.2321 15.1321
#> 0.12 1.2544 15.0544
#> 0.13 1.2769 14.9769
#> 0.14 1.2996 14.8996
#> 0.15 1.3225 14.8225
#> 0.16 1.3456 14.7456
#> 0.17 1.3689 14.6689
#> 0.18 1.3924 14.5924
#> 0.19 1.4161 14.5161
#> 0.20 1.4400 14.4400
#> 0.21 1.4641 14.3641
#> 0.22 1.4884 14.2884
#> 0.23 1.5129 14.2129
#> 0.24 1.5376 14.1376
#> 0.25 1.5625 14.0625
#> 0.26 1.5876 13.9876
#> 0.27 1.6129 13.9129
#> 0.28 1.6384 13.8384
#> 0.29 1.6641 13.7641
#> 0.30 1.6900 13.6900
#> 0.31 1.7161 13.6161
#> 0.32 1.7424 13.5424
#> 0.33 1.7689 13.4689
#> 0.34 1.7956 13.3956
#> 0.35 1.8225 13.3225
#> 0.36 1.8496 13.2496
#> 0.37 1.8769 13.1769
#> 0.38 1.9044 13.1044
#> 0.39 1.9321 13.0321
#> 0.40 1.9600 12.9600
#> 0.41 1.9881 12.8881
#> 0.42 2.0164 12.8164
#> 0.43 2.0449 12.7449
#> 0.44 2.0736 12.6736
#> 0.45 2.1025 12.6025
#> 0.46 2.1316 12.5316
#> 0.47 2.1609 12.4609
#> 0.48 2.1904 12.3904
#> 0.49 2.2201 12.3201
#> 0.50 2.2500 12.2500
#> 0.51 2.2801 12.1801
#> 0.52 2.3104 12.1104
#> 0.53 2.3409 12.0409
#> 0.54 2.3716 11.9716
#> 0.55 2.4025 11.9025
#> 0.56 2.4336 11.8336
#> 0.57 2.4649 11.7649
#> 0.58 2.4964 11.6964
#> 0.59 2.5281 11.6281
#> 0.60 2.5600 11.5600
#> 0.61 2.5921 11.4921
#> 0.62 2.6244 11.4244
#> 0.63 2.6569 11.3569
#> 0.64 2.6896 11.2896
#> 0.65 2.7225 11.2225
#> 0.66 2.7556 11.1556
#> 0.67 2.7889 11.0889
#> 0.68 2.8224 11.0224
#> 0.69 2.8561 10.9561
#> 0.70 2.8900 10.8900
#> 0.71 2.9241 10.8241
#> 0.72 2.9584 10.7584
#> 0.73 2.9929 10.6929
#> 0.74 3.0276 10.6276
#> 0.75 3.0625 10.5625
#> 0.76 3.0976 10.4976
#> 0.77 3.1329 10.4329
#> 0.78 3.1684 10.3684
#> 0.79 3.2041 10.3041
#> 0.80 3.2400 10.2400
#> 0.81 3.2761 10.1761
#> 0.82 3.3124 10.1124
#> 0.83 3.3489 10.0489
#> 0.84 3.3856  9.9856
#> 0.85 3.4225  9.9225
#> 0.86 3.4596  9.8596
#> 0.87 3.4969  9.7969
#> 0.88 3.5344  9.7344
#> 0.89 3.5721  9.6721
#> 0.90 3.6100  9.6100
#> 0.91 3.6481  9.5481
#> 0.92 3.6864  9.4864
#> 0.93 3.7249  9.4249
#> 0.94 3.7636  9.3636
#> 0.95 3.8025  9.3025
#> 0.96 3.8416  9.2416
#> 0.97 3.8809  9.1809
#> 0.98 3.9204  9.1204
#> 0.99 3.9601  9.0601
#> 1.00 4.0000  9.0000

is.fuzzification(): Verifies if a matrix is a fuzzification matrix

FuzzySTs::is.fuzzification() checks if a array can be a fuzzification matrix of a given variable. If it is verified, the considered array should fulfill the following requirements: It should be an array composed by 3 dimensions (m, n, p), where the number of lines m is the number of observations in the data set, the number of columns n is the number of chosen breakpoints, and the third dimension should be fixed to the value \(p=2\) (related to the left and right alpha-cuts of a fuzzy number). The numbers of lines and columns should be the same for dimensions \(p=1\), i.e. left, and \(p=2\) i.e. right.

mat <- array(c(1,1,2,2,3,3,5,5,6,6,7,7),dim=c(2,3,2))
is.fuzzification(mat)
#> [1] TRUE

is.trfuzzification(): Verifies if a matrix is a fuzzification matrix of trapezoidal fuzzy numbers

FuzzySTs::is.trfuzzification() checks if a considered matrix can be a matrix of fuzzification of a variable modelled by trapezoidal fuzzy numbers written by the quadruple (p,q,r,s). The matrix should be composed by 4 columns (p,q,r,s), such that p \(\leq\) q \(\leq\) r \(\leq\) s, where the number of lines corresponds to the number of observations of the data set. Note that for triangular fuzzy numbers, the column q is equal to the column r.

mat <- matrix(c(1,1,2,2,3,3,4,4),ncol=4)
is.trfuzzification(mat)
#> [1] TRUE

tr.gfuzz(): Transforms a trapezoidal fuzzification matrix into a numerical one

FuzzySTs::tr.gfuzz() transforms a trapezoidal fuzzification matrix such that is.trfuzzification = TRUE, to a 3-dimensional numerical fuzzification matrix for which is.fuzzification = TRUE.

data <- matrix(c(1,1,2,2,3,3,4,4),ncol=4)
data.tr <- tr.gfuzz(data)

FUZZ(): Fuzzifies a variable modelled by trapezoidal or triangular fuzzy numbers

FuzzySTs::FUZZ() fuzzifies a variable modelled by trapezoidal or triangular fuzzy numbers. The output is such that is.trfuzzification = TRUE. The membership functions are required. They should be introduced in the following manner: they should be called “MF” attached to the index of the main-item followed by the one of the sub-item i.e. the variable, and finally the index of the linguistic term. Note that the decomposition in supposed to be in main-items and sub-items. This syntax is the same as the one used in the fuzzification process of the package FuzzyToolkitUoN.

To illustrate the programming language related to the syntax of the membership functions of the modelling fuzzy numbers, we propose this following example:

Consider a data set composed by 5 linguistic variables. The aim is to fuzzify the fourth variable of a given data base. For this example, we suppose that the decomposition in main and sub-items is needed. We propose to divide the data set into \(2\) main-items as given in the following table. For each linguistic term of the considered variable, one has to choose a corresponding modelling fuzzy number. Suppose we want to model the linguistic \(L_{213}\), i.e. the third linguistic term of the first variable found in the second main-item, by a fuzzy number written as \(\tilde{L}_{213}\). Its membership function should then be expressed by MF213 as follows:

Decomposition 1
Main-item ({mi=1}) Main-item ({mi=2})
Sub-item 1 Sub-item 2 Sub-item 3 Sub-item 1 Sub-item 2
si=1 si=2 si=3 si=1 si=2
\(\tilde{L}_{111}\) MF111 \(\tilde{L}_{121}\) MF121 \(\tilde{L}_{131}\) MF131 \(\tilde{L}_{211}\) MF211 \(\tilde{L}_{221}\) MF221
\(\tilde{L}_{112}\) MF112 \(\tilde{L}_{122}\) MF122 \(\tilde{L}_{132}\) MF132 \(\tilde{L}_{212}\) MF212 \(\tilde{L}_{222}\) MF222
\(\tilde{L}_{113}\) MF113 \(\tilde{L}_{123}\) MF123 \(\tilde{L}_{133}\) MF133 \(\tilde{L}_{213}\) MF213
\(\tilde{L}_{114}\) MF114 \(\tilde{L}_{134}\) MF134 \(\tilde{L}_{214}\) MF214

If the decomposition in main and sub-items is not required, it is then recommended to fix the index of the main-item to \(1\). Consequently, the index of the sub-item will be nothing but the column position of the variable in the architecture of the data set. For the same example previously described where the fourth variable has to be fuzzified, suppose that no decomposition is desired, then the architecture becomes as seen in the following table . Therefore, the considered linguistic term \(L_{213}\) of the previous example is now on called \(L_{143}\) with its corresponding fuzzy number \(\tilde{L}_{143}\). Its membership function will afterwards be denoted by MF143 as given by:

Decomposition 2
Main-item ({mi=1})
Sub-item 1 Sub-item 2 Sub-item 3 Sub-item 4 Sub-item 5
si=1 si=2 si=3 si=4 si=5
\(\tilde{L}_{111}\) MF111 \(\tilde{L}_{121}\) MF121 \(\tilde{L}_{131}\) MF131 \(\tilde{L}_{141}\) MF141 \(\tilde{L}_{151}\) MF151
\(\tilde{L}_{112}\) MF112 \(\tilde{L}_{122}\) MF122 \(\tilde{L}_{132}\) MF132 \(\tilde{L}_{142}\) MF142 \(\tilde{L}_{152}\) MF152
\(\tilde{L}_{113}\) MF113 \(\tilde{L}_{123}\) MF123 \(\tilde{L}_{133}\) MF133 \(\tilde{L}_{143}\) MF143
\(\tilde{L}_{114}\) MF114 \(\tilde{L}_{134}\) MF134 \(\tilde{L}_{144}\) MF144
# Fuzzification of the first sub-item of a data set - No decomposition is required 
data <- matrix(c(1,2,3,2,2,1,1,3,1,2),ncol=1)
MF111 <- TrapezoidalFuzzyNumber(0,1,1,2)
MF112 <- TrapezoidalFuzzyNumber(1,2,2,3)
MF113 <- TrapezoidalFuzzyNumber(2,3,3,3)
PA11 <- c(1,2,3)
data.fuzzified <- FUZZ(data,mi=1,si=1,PA=PA11)
is.trfuzzification(data.fuzzified)
#> [1] TRUE