| Title: | Simulation of Piecewise Linear Fuzzy Numbers |
|---|---|
| Description: | The definition of fuzzy random variable and the methods of simulation from fuzzy random variables are two challenging statistical problems in three recent decades. This package is organized based on a special definition of fuzzy random variable and simulate fuzzy random variable by Piecewise Linear Fuzzy Numbers (PLFNs); see Coroianua et al. (2013) <doi:10.1016/j.fss.2013.02.005> for details about PLFNs. Some important statistical functions are considered for obtaining the membership function of main statistics, such as mean, variance, summation, standard deviation and coefficient of variance. Some of applied advantages of 'Sim.PLFN' package are: (1) Easily generating / simulation a random sample of PLFN, (2) drawing the membership functions of the simulated PLFNs or the membership function of the statistical result, and (3) Considering the simulated PLFNs for arithmetic operation or importing into some statistical computation. Finally, it must be mentioned that 'Sim.PLFN' package works on the basis of 'FuzzyNumbers' package. |
| Authors: | Abbas Parchami (Department of Statistics, Faculty of Mathematics and Computer, Shahid Bahonar University of Kerman, Kerman, Iran) |
| Maintainer: | Abbas Parchami <[email protected]> |
| License: | LGPL (>= 3) |
| Version: | 1.0 |
| Built: | 2026-05-16 06:45:31 UTC |
| Source: | https://github.com/cran/Sim.PLFN |
This package is organized based on a special definition of fuzzy random variable and simulate fuzzy random variable by Piecewise Linear Fuzzy Numbers (PLFNs). Some important statistical functions are considered for obtaining the membership function of main statistics, such as mean, variance, summation, standard deviation and coefficient of variance. Some of applied advantages of 'Sim.PLFN' Package are: (1) Easily generating / simulation a random sample of PLFN, (2) drawing the membership functions of the simulated PLFNs or the membership function of the statistical result, and (3) Considering the simulated PLFNs for arithmetic operation or importing into some statistical computation.
Abbas Parchami
Coroianua, L., Gagolewski, M., Grzegorzewski, P. (2013) Nearest piecewiselinearapproximationoffuzzynumbers. Fuzzy Sets and Systems 233, 26-51.
Gagolewski, M., Caha, J. (2015) FuzzyNumbers Package: Tools to deal with fuzzy numbers in R. R package version 0.4-1, https://cran.r-project.org/web/packages=FuzzyNumbers
Gagolewski, M., Caha, J. (2015) A guide to the FuzzyNumbers package for R (FuzzyNumbers version 0.4-1) http://FuzzyNumbers.rexamine.com
DISTRIB FuzzyNumbers FuzzyNumbers.Ext.2 Calculator.LR.FNs
library(FuzzyNumbers) # Example 1: Let x ~~ ( X~N(0,.2) ; s_X^l~Exp(3) ; s_X^r~beta(1,3) ) n=3; knot.n=3 Sample <- S.PLFN( n, knot.n, type="PLFI", X.dist="norm", X.dist.par=c(0,.2), slX.dist="exp", slX.dist.par=3, srX.dist="beta", srX.dist.par=c(1,3) ) Sample Sample[,,3] # For plotting random fuzzy sample: xlim = c( min(Sample), max(Sample) ) plot( cuts.to.PLFN(Sample[,,1]), type="o", xlim=xlim ) plot( cuts.to.PLFN(Sample[,,2]), type="o", add=TRUE ) plot( cuts.to.PLFN(Sample[,,3]), type="o", add=TRUE ) abline( h=round((knot.n+1):0/(knot.n+1),4), lty=3, col="gray70") # Example 2: n=9; knot.n=9 Sample <- S.PLFN( n, knot.n, X.dist="norm", X.dist.par=c(5,2), slX.dist="chisq", slX.dist.par=1, srX.dist="unif", srX.dist.par=c(0,3) ) Sample Sample[,,9] # For plotting random fuzzy sample: xlim = c( min(Sample), max(Sample) ) plot( cuts.to.PLFN(Sample[,,1]), type="b", col=1, xlim=xlim ) plot( cuts.to.PLFN(Sample[,,2]), type="b", col=2, add=TRUE ) plot( cuts.to.PLFN(Sample[,,3]), type="b", col=3, add=TRUE ) plot( cuts.to.PLFN(Sample[,,4]), type="b", col=4, add=TRUE ) plot( cuts.to.PLFN(Sample[,,5]), type="b", col=5, add=TRUE ) plot( cuts.to.PLFN(Sample[,,6]), type="b", col=6, add=TRUE ) plot( cuts.to.PLFN(Sample[,,7]), type="b", col=7, add=TRUE ) plot( cuts.to.PLFN(Sample[,,8]), type="b", col=8, add=TRUE ) plot( cuts.to.PLFN(Sample[,,9]), type="b", col=9, add=TRUE ) abline( h=round((knot.n+1):0/(knot.n+1),4), lty=3, col="gray70") # Example 3: (Four Arithmatic Operations on PLFNs) if(!require(FuzzyNumbers)){install.packages("FuzzyNumbers")} library(FuzzyNumbers) Sample <- S.PLFN( n=2, knot.n=9, X.dist="unif", X.dist.par=c(1,3), slX.dist="beta", slX.dist.par=c(4,3), srX.dist="beta", srX.dist.par=c(1/3,2/3) ) Sample # For plotting random fuzzy sample: xlim = c( min(Sample), max(Sample) ) plot( cuts.to.PLFN(Sample[,,1]), type="b", xlim=xlim ) plot( cuts.to.PLFN(Sample[,,2]), type="b", add=TRUE ) abline( h=round((knot.n+1):0/(knot.n+1),4), lty=3, col="gray70") X1 = cuts.to.PLFN( Sample[,,1] ) X2 = cuts.to.PLFN( Sample[,,2] ) ### Now working with four arithmatic operations +, _, * and / are simple as follows: summ = X1 + X2 ; summ dist = X1 - X2 ; dist prod = X1 * X2 ; prod divi = X1 / X2 ; divi xlim = c(min(summ["a1"],dist["a1"],prod["a1"],divi["a1"]), max(summ["a4"],dist["a4"],prod["a4"],divi["a4"]) ) # For plotting random fuzzy sample: plot( cuts.to.PLFN(Sample[,,1]), type="b", xlim=xlim ) plot( cuts.to.PLFN(Sample[,,2]), type="b", add=TRUE ) abline( h=round((knot.n+1):0/(knot.n+1),4), lty=3, col="gray70") plot(summ, type="b", xlim=c(0, 12), add=TRUE, col=2, lwd=2) plot(dist, type="b", xlim=c(0, 12), add=TRUE, col=3, lwd=2) plot(prod, type="b", xlim=c(0, 12), add=TRUE, col=4, lwd=2) plot(divi, type="b", xlim=c(0, 12), add=TRUE, col=5, lwd=2) abline(v=c(X1["a2"],X2["a2"],summ["a2"],dist["a2"],prod["a2"],divi["a2"]), col= c(1,1,2,3,4,5), lty=3) legend( "topright", c("X1 & X2", "X1 + X2", "X1 - X2", "X1 * X2", "X1 / X2"), col=1:5, text.col = 1, lwd=2 )library(FuzzyNumbers) # Example 1: Let x ~~ ( X~N(0,.2) ; s_X^l~Exp(3) ; s_X^r~beta(1,3) ) n=3; knot.n=3 Sample <- S.PLFN( n, knot.n, type="PLFI", X.dist="norm", X.dist.par=c(0,.2), slX.dist="exp", slX.dist.par=3, srX.dist="beta", srX.dist.par=c(1,3) ) Sample Sample[,,3] # For plotting random fuzzy sample: xlim = c( min(Sample), max(Sample) ) plot( cuts.to.PLFN(Sample[,,1]), type="o", xlim=xlim ) plot( cuts.to.PLFN(Sample[,,2]), type="o", add=TRUE ) plot( cuts.to.PLFN(Sample[,,3]), type="o", add=TRUE ) abline( h=round((knot.n+1):0/(knot.n+1),4), lty=3, col="gray70") # Example 2: n=9; knot.n=9 Sample <- S.PLFN( n, knot.n, X.dist="norm", X.dist.par=c(5,2), slX.dist="chisq", slX.dist.par=1, srX.dist="unif", srX.dist.par=c(0,3) ) Sample Sample[,,9] # For plotting random fuzzy sample: xlim = c( min(Sample), max(Sample) ) plot( cuts.to.PLFN(Sample[,,1]), type="b", col=1, xlim=xlim ) plot( cuts.to.PLFN(Sample[,,2]), type="b", col=2, add=TRUE ) plot( cuts.to.PLFN(Sample[,,3]), type="b", col=3, add=TRUE ) plot( cuts.to.PLFN(Sample[,,4]), type="b", col=4, add=TRUE ) plot( cuts.to.PLFN(Sample[,,5]), type="b", col=5, add=TRUE ) plot( cuts.to.PLFN(Sample[,,6]), type="b", col=6, add=TRUE ) plot( cuts.to.PLFN(Sample[,,7]), type="b", col=7, add=TRUE ) plot( cuts.to.PLFN(Sample[,,8]), type="b", col=8, add=TRUE ) plot( cuts.to.PLFN(Sample[,,9]), type="b", col=9, add=TRUE ) abline( h=round((knot.n+1):0/(knot.n+1),4), lty=3, col="gray70") # Example 3: (Four Arithmatic Operations on PLFNs) if(!require(FuzzyNumbers)){install.packages("FuzzyNumbers")} library(FuzzyNumbers) Sample <- S.PLFN( n=2, knot.n=9, X.dist="unif", X.dist.par=c(1,3), slX.dist="beta", slX.dist.par=c(4,3), srX.dist="beta", srX.dist.par=c(1/3,2/3) ) Sample # For plotting random fuzzy sample: xlim = c( min(Sample), max(Sample) ) plot( cuts.to.PLFN(Sample[,,1]), type="b", xlim=xlim ) plot( cuts.to.PLFN(Sample[,,2]), type="b", add=TRUE ) abline( h=round((knot.n+1):0/(knot.n+1),4), lty=3, col="gray70") X1 = cuts.to.PLFN( Sample[,,1] ) X2 = cuts.to.PLFN( Sample[,,2] ) ### Now working with four arithmatic operations +, _, * and / are simple as follows: summ = X1 + X2 ; summ dist = X1 - X2 ; dist prod = X1 * X2 ; prod divi = X1 / X2 ; divi xlim = c(min(summ["a1"],dist["a1"],prod["a1"],divi["a1"]), max(summ["a4"],dist["a4"],prod["a4"],divi["a4"]) ) # For plotting random fuzzy sample: plot( cuts.to.PLFN(Sample[,,1]), type="b", xlim=xlim ) plot( cuts.to.PLFN(Sample[,,2]), type="b", add=TRUE ) abline( h=round((knot.n+1):0/(knot.n+1),4), lty=3, col="gray70") plot(summ, type="b", xlim=c(0, 12), add=TRUE, col=2, lwd=2) plot(dist, type="b", xlim=c(0, 12), add=TRUE, col=3, lwd=2) plot(prod, type="b", xlim=c(0, 12), add=TRUE, col=4, lwd=2) plot(divi, type="b", xlim=c(0, 12), add=TRUE, col=5, lwd=2) abline(v=c(X1["a2"],X2["a2"],summ["a2"],dist["a2"],prod["a2"],divi["a2"]), col= c(1,1,2,3,4,5), lty=3) legend( "topright", c("X1 & X2", "X1 + X2", "X1 - X2", "X1 * X2", "X1 / X2"), col=1:5, text.col = 1, lwd=2 )
This function can easily covert a cuts matrix into a Piecewise Linear Fuzzy Number.
cuts.to.PLFN(cuts)cuts.to.PLFN(cuts)
cuts |
A matrices, with knot.n raw and 2 column, which contains all information about a Piecewise Linear Fuzzy Number. |
This function returned a Piecewise Linear Fuzzy Number.
Gagolewski, M., Caha, J. (2015) FuzzyNumbers Package: Tools to deal with fuzzy numbers in R. R package version 0.4-1, https://cran.r-project.org/web/packages=FuzzyNumbers
Gagolewski, M., Caha, J. (2015) A guide to the FuzzyNumbers package for R (FuzzyNumbers version 0.4-1) http://FuzzyNumbers.rexamine.com
DISTRIB FuzzyNumbers FuzzyNumbers.Ext.2 Calculator.LR.FNs
if(!require(FuzzyNumbers)){install.packages("FuzzyNumbers")} library(FuzzyNumbers) knot.n = 2 T <- PLFN( knot.n=knot.n, X.dist="norm", X.dist.par=c(0,1), slX.dist="exp", slX.dist.par=3, srX.dist="beta", srX.dist.par=c(1,3) ) T plot(T, type="b") CUTS <- PLFN.to.cuts(T, knot.n) CUTS T2 = cuts.to.PLFN(CUTS) plot(T2, type="b", col=2, add=TRUE, lwd=3, lty=3)if(!require(FuzzyNumbers)){install.packages("FuzzyNumbers")} library(FuzzyNumbers) knot.n = 2 T <- PLFN( knot.n=knot.n, X.dist="norm", X.dist.par=c(0,1), slX.dist="exp", slX.dist.par=3, srX.dist="beta", srX.dist.par=c(1,3) ) T plot(T, type="b") CUTS <- PLFN.to.cuts(T, knot.n) CUTS T2 = cuts.to.PLFN(CUTS) plot(T2, type="b", col=2, add=TRUE, lwd=3, lty=3)
This function is able to calculate the coefficient of variation (CV) of a sample from Piecewise Linear Fuzzy Numbers (PLFNs).
CV(S.PLFN)CV(S.PLFN)
S.PLFN |
A sample from Piecewise Linear Fuzzy Numbers (PLFNs), with n PLFNs. This sample is an array with |
This function returned a Piecewise Linear Fuzzy Number as the coefficient of variation of several PLFNs.
DISTRIB FuzzyNumbers FuzzyNumbers.Ext.2 Calculator.LR.FNs
library(FuzzyNumbers) n=3; knot.n=4 Sample <- S.PLFN( n, knot.n, X.dist="norm", X.dist.par=c(3,2), slX.dist="exp", slX.dist.par=3, srX.dist="beta", srX.dist.par=c(1,3) ) Sample # For plotting random fuzzy sample: xlim = c(0, max(Sample[knot.n+2,2,])) plot( cuts.to.PLFN(Sample[,,1]), type="b", xlim=xlim ) plot( cuts.to.PLFN(Sample[,,2]), type="b", add=TRUE ) plot( cuts.to.PLFN(Sample[,,3]), type="b", add=TRUE ) abline( h=round((knot.n+1):0/(knot.n+1),4), lty=3, col="gray70") FuzzyNumbers::plot(Mean(Sample), col=4, lwd=2, add=TRUE, type="b") plot(Var(Sample), col=3, lwd=2, add=TRUE, type="b") plot(Sd(Sample), col=6, lwd=2, add=TRUE, type="b") CV = CV(Sample) CV PLFN.to.cuts(CV, knot.n) plot(CV, col=2, lwd=2, add=TRUE, type="b")library(FuzzyNumbers) n=3; knot.n=4 Sample <- S.PLFN( n, knot.n, X.dist="norm", X.dist.par=c(3,2), slX.dist="exp", slX.dist.par=3, srX.dist="beta", srX.dist.par=c(1,3) ) Sample # For plotting random fuzzy sample: xlim = c(0, max(Sample[knot.n+2,2,])) plot( cuts.to.PLFN(Sample[,,1]), type="b", xlim=xlim ) plot( cuts.to.PLFN(Sample[,,2]), type="b", add=TRUE ) plot( cuts.to.PLFN(Sample[,,3]), type="b", add=TRUE ) abline( h=round((knot.n+1):0/(knot.n+1),4), lty=3, col="gray70") FuzzyNumbers::plot(Mean(Sample), col=4, lwd=2, add=TRUE, type="b") plot(Var(Sample), col=3, lwd=2, add=TRUE, type="b") plot(Sd(Sample), col=6, lwd=2, add=TRUE, type="b") CV = CV(Sample) CV PLFN.to.cuts(CV, knot.n) plot(CV, col=2, lwd=2, add=TRUE, type="b")
This function is able to calculate the mean (average) of a sample from Piecewise Linear Fuzzy Numbers (PLFNs).
Mean(S.PLFN)Mean(S.PLFN)
S.PLFN |
A sample from Piecewise Linear Fuzzy Numbers (PLFNs), with n PLFNs. This sample is an array with |
This function returned a Piecewise Linear Fuzzy Number.
DISTRIB FuzzyNumbers FuzzyNumbers.Ext.2 Calculator.LR.FNs
library(FuzzyNumbers) n=3; knot.n=4 Sample <- S.PLFN( n, knot.n, X.dist="pois", X.dist.par=5, slX.dist="exp", slX.dist.par=3, srX.dist="beta", srX.dist.par=c(1,3) ) Sample # For plotting random fuzzy sample: xlim = c( min(Sample), max(Sample) ) plot( cuts.to.PLFN(Sample[,,1]), type="b", xlim=xlim ) plot( cuts.to.PLFN(Sample[,,2]), type="b", add=TRUE ) plot( cuts.to.PLFN(Sample[,,3]), type="b", add=TRUE ) abline( h=round((knot.n+1):0/(knot.n+1),4), lty=3, col="gray70") M = Mean(Sample) M plot( M, type="b", add=TRUE, col=2, lwd=3 )library(FuzzyNumbers) n=3; knot.n=4 Sample <- S.PLFN( n, knot.n, X.dist="pois", X.dist.par=5, slX.dist="exp", slX.dist.par=3, srX.dist="beta", srX.dist.par=c(1,3) ) Sample # For plotting random fuzzy sample: xlim = c( min(Sample), max(Sample) ) plot( cuts.to.PLFN(Sample[,,1]), type="b", xlim=xlim ) plot( cuts.to.PLFN(Sample[,,2]), type="b", add=TRUE ) plot( cuts.to.PLFN(Sample[,,3]), type="b", add=TRUE ) abline( h=round((knot.n+1):0/(knot.n+1),4), lty=3, col="gray70") M = Mean(Sample) M plot( M, type="b", add=TRUE, col=2, lwd=3 )
This function is able to produce / simulate a Piecewise Linear Fuzzy Number (PLFN).
PLFN(knot.n, type = "PLFN", X.dist, X.dist.par, slX.dist, slX.dist.par, srX.dist, srX.dist.par)PLFN(knot.n, type = "PLFN", X.dist, X.dist.par, slX.dist, slX.dist.par, srX.dist, srX.dist.par)
knot.n |
the number of knots; see package |
type |
The possible values of this argument is |
X.dist |
The distribution name of the random variable (for simulate the core of random fuzzy number) is determined by characteristic element |
X.dist.par |
A vector of distribution parameters (for simulate the core of random fuzzy number) with considered ordering in |
slX.dist |
The distribution name of the random variable (for simulate the left spread value of random fuzzy number) is determined by characteristic element |
slX.dist.par |
A vector of distribution parameters (for simulate the left spread value of random fuzzy number) with considered ordering in |
srX.dist |
The distribution name of the random variable (for simulate the right spread value of random fuzzy number) is determined by characteristic element |
srX.dist.par |
A vector of distribution parameters (for simulate the right spread value of random fuzzy number) with considered ordering in |
Considering the type argument, this function returned/simulate/create one of following fuzzy numbers:
(1) Triangular Fuzzy Number,
(2) Trapezoidal Fuzzy Number,
(3) Piecewise Linear Fuzzy Number, and
(4) Piecewise Linear Fuzzy Interval.
Gagolewski, M., Caha, J. (2015) FuzzyNumbers Package: Tools to deal with fuzzy numbers in R. R package version 0.4-1, https://cran.r-project.org/web/packages=FuzzyNumbers
Gagolewski, M., Caha, J. (2015) A guide to the FuzzyNumbers package for R (FuzzyNumbers version 0.4-1) http://FuzzyNumbers.rexamine.com
DISTRIB FuzzyNumbers FuzzyNumbers.Ext.2 Calculator.LR.FNs
# Example: Let x ~~ ( X~N(3,0.2) ; s_X^l~Exp(3) ; s_X^r~U(0,2) ) if(!require(FuzzyNumbers)){install.packages("FuzzyNumbers")} library(FuzzyNumbers) knot.n = 2 P <- PLFN( knot.n, type="Tri", X.dist="norm", X.dist.par=c(3,.2), slX.dist="exp", slX.dist.par=3, srX.dist="unif", srX.dist.par=c(0,2) ) P plot(P, lwd=3, type="b") abline( h=round((knot.n+1):0/(knot.n+1),4), v=alphacut(P, round((knot.n+1):0/(knot.n+1),4) ), lty=3, col=2 ) P <- PLFN( knot.n, type="Tra", X.dist="norm", X.dist.par=c(3,1), slX.dist="exp", slX.dist.par=3, srX.dist="unif", srX.dist.par=c(0,2) ) plot(P, lwd=3, type="b") abline( h=round((knot.n+1):0/(knot.n+1),4), v=alphacut(P, round((knot.n+1):0/(knot.n+1),4) ), lty=3, col=2 ) knot.n = 2 P <- PLFN( knot.n, #Defult: type="PLFN" X.dist="norm", X.dist.par=c(3,1), slX.dist="exp", slX.dist.par=3, srX.dist="unif", srX.dist.par=c(0,2) ) plot(P, lwd=3) abline( h=round((knot.n+1):0/(knot.n+1),4), v=alphacut(P, round((knot.n+1):0/(knot.n+1),4) ), lty=3, col=2 ) #Try once again by knot.n=10 knot.n = 2 P <- PLFN( knot.n, type="PLFI", X.dist="norm", X.dist.par=c(3,1), slX.dist="exp", slX.dist.par=3, srX.dist="unif", srX.dist.par=c(0,2) ) plot(P, lwd=3, type="b") abline( h=round((knot.n+1):0/(knot.n+1),4), v=alphacut(P, round((knot.n+1):0/(knot.n+1),4) ), lty=3, col=2 ) plot(P, type="b", col=2, lty=1, lwd=3, add=FALSE) # Some of possible types are: # "p" for points, # "l" for lines, # "b" for both, # "c" for the lines part alone of "b", # "o" for both over plotted, # "h" for histogram like (or high-density) vertical lines, # "s" for stair steps, # "S" for other steps, # "n" for no plotting. P P["a1"] #First point of support P["a2"] #First point of core P["a3"] #End point of core P["a4"] #End point of support core(P) supp(P) alphacut(P, 0.5) abline(h=.5, lty=3) evaluate(P, 3.5) round( evaluate(P, seq(0,4, by=.5)), 2)# Example: Let x ~~ ( X~N(3,0.2) ; s_X^l~Exp(3) ; s_X^r~U(0,2) ) if(!require(FuzzyNumbers)){install.packages("FuzzyNumbers")} library(FuzzyNumbers) knot.n = 2 P <- PLFN( knot.n, type="Tri", X.dist="norm", X.dist.par=c(3,.2), slX.dist="exp", slX.dist.par=3, srX.dist="unif", srX.dist.par=c(0,2) ) P plot(P, lwd=3, type="b") abline( h=round((knot.n+1):0/(knot.n+1),4), v=alphacut(P, round((knot.n+1):0/(knot.n+1),4) ), lty=3, col=2 ) P <- PLFN( knot.n, type="Tra", X.dist="norm", X.dist.par=c(3,1), slX.dist="exp", slX.dist.par=3, srX.dist="unif", srX.dist.par=c(0,2) ) plot(P, lwd=3, type="b") abline( h=round((knot.n+1):0/(knot.n+1),4), v=alphacut(P, round((knot.n+1):0/(knot.n+1),4) ), lty=3, col=2 ) knot.n = 2 P <- PLFN( knot.n, #Defult: type="PLFN" X.dist="norm", X.dist.par=c(3,1), slX.dist="exp", slX.dist.par=3, srX.dist="unif", srX.dist.par=c(0,2) ) plot(P, lwd=3) abline( h=round((knot.n+1):0/(knot.n+1),4), v=alphacut(P, round((knot.n+1):0/(knot.n+1),4) ), lty=3, col=2 ) #Try once again by knot.n=10 knot.n = 2 P <- PLFN( knot.n, type="PLFI", X.dist="norm", X.dist.par=c(3,1), slX.dist="exp", slX.dist.par=3, srX.dist="unif", srX.dist.par=c(0,2) ) plot(P, lwd=3, type="b") abline( h=round((knot.n+1):0/(knot.n+1),4), v=alphacut(P, round((knot.n+1):0/(knot.n+1),4) ), lty=3, col=2 ) plot(P, type="b", col=2, lty=1, lwd=3, add=FALSE) # Some of possible types are: # "p" for points, # "l" for lines, # "b" for both, # "c" for the lines part alone of "b", # "o" for both over plotted, # "h" for histogram like (or high-density) vertical lines, # "s" for stair steps, # "S" for other steps, # "n" for no plotting. P P["a1"] #First point of support P["a2"] #First point of core P["a3"] #End point of core P["a4"] #End point of support core(P) supp(P) alphacut(P, 0.5) abline(h=.5, lty=3) evaluate(P, 3.5) round( evaluate(P, seq(0,4, by=.5)), 2)
This function can easily covert a Piecewise Linear Fuzzy Number (PLFN) into a cuts matrix.
PLFN.to.cuts(P, knot.n)PLFN.to.cuts(P, knot.n)
P |
A Piecewise Linear Fuzzy Number (PLFN). |
knot.n |
the number of knots; see package |
This function returned a matrix which contains core, support and knot.n cuts of the considered PLFN.
DISTRIB FuzzyNumbers FuzzyNumbers.Ext.2 Calculator.LR.FNs
knot.n = 2 T <- PLFN( knot.n=knot.n, X.dist="norm", X.dist.par=c(0,1), slX.dist="exp", slX.dist.par=3, srX.dist="beta", srX.dist.par=c(1,3) ) T FuzzyNumbers::plot(T, type="b") cuts = PLFN.to.cuts(T, knot.n) cuts cuts[,"L"] #Lower bounds of cuts cuts[,"U"] #Upper bounds of cuts cuts[2,] #Or equivalently cuts["0.6667",]knot.n = 2 T <- PLFN( knot.n=knot.n, X.dist="norm", X.dist.par=c(0,1), slX.dist="exp", slX.dist.par=3, srX.dist="beta", srX.dist.par=c(1,3) ) T FuzzyNumbers::plot(T, type="b") cuts = PLFN.to.cuts(T, knot.n) cuts cuts[,"L"] #Lower bounds of cuts cuts[,"U"] #Upper bounds of cuts cuts[2,] #Or equivalently cuts["0.6667",]
This function is able to produce / simulate a random sample from Piecewise Linear Fuzzy Numbers (PLFNs).
S.PLFN(n, knot.n, type = "PLFN", X.dist, X.dist.par, slX.dist, slX.dist.par, srX.dist, srX.dist.par )S.PLFN(n, knot.n, type = "PLFN", X.dist, X.dist.par, slX.dist, slX.dist.par, srX.dist, srX.dist.par )
n |
the size of random sample of PLSNs. |
knot.n |
the number of knots; see package |
type |
The possible values of this argument is |
X.dist |
The distribution name of the random variable (for simulate the core of random fuzzy number) is determined by characteristic element |
X.dist.par |
A vector of distribution parameters (for simulate the core of random fuzzy number) with considered ordering in |
slX.dist |
The distribution name of the random variable (for simulate the left spread value of random fuzzy number) is determined by characteristic element |
slX.dist.par |
A vector of distribution parameters (for simulate the left spread value of random fuzzy number) with considered ordering in |
srX.dist |
The distribution name of the random variable (for simulate the right spread value of random fuzzy number) is determined by characteristic element |
srX.dist.par |
A vector of distribution parameters (for simulate the right spread value of random fuzzy number) with considered ordering in |
Considering the type argument, this function returned/simulate/create one of following fuzzy numbers:
(1) Triangular Fuzzy Number,
(2) Trapezoidal Fuzzy Number,
(3) Piecewise Linear Fuzzy Number, and
(4) Piecewise Linear Fuzzy Interval.
Gagolewski, M., Caha, J. (2015) FuzzyNumbers Package: Tools to deal with fuzzy numbers in R. R package version 0.4-1, https://cran.r-project.org/web/packages=FuzzyNumbers
Gagolewski, M., Caha, J. (2015) A guide to the FuzzyNumbers package for R (FuzzyNumbers version 0.4-1) http://FuzzyNumbers.rexamine.com
DISTRIB FuzzyNumbers FuzzyNumbers.Ext.2 Calculator.LR.FNs
library(FuzzyNumbers) # Let x ~~ ( X~N(0,1) ; s_X^l~Exp(3) ; s_X^r~beta(1,3) ) n=3; knot.n=3 Sam <- S.PLFN( n=3, knot.n=4, type="Tra", X.dist="norm", X.dist.par=c(0,1), slX.dist="exp", slX.dist.par=3, srX.dist="beta", srX.dist.par=c(1,3) ) Sam Sam[,,"X3"] # For plotting random fuzzy sample: xlim = c( min(Sam), max(Sam) ) plot( cuts.to.PLFN(Sam[,,1]), type="b", col=1, xlim=xlim ) plot( cuts.to.PLFN(Sam[,,2]), type="b", col=2, add=TRUE ) plot( cuts.to.PLFN(Sam[,,3]), type="b", col=3, add=TRUE ) abline( h=round((knot.n+1):0/(knot.n+1),4), lty=3, col="gray70")library(FuzzyNumbers) # Let x ~~ ( X~N(0,1) ; s_X^l~Exp(3) ; s_X^r~beta(1,3) ) n=3; knot.n=3 Sam <- S.PLFN( n=3, knot.n=4, type="Tra", X.dist="norm", X.dist.par=c(0,1), slX.dist="exp", slX.dist.par=3, srX.dist="beta", srX.dist.par=c(1,3) ) Sam Sam[,,"X3"] # For plotting random fuzzy sample: xlim = c( min(Sam), max(Sam) ) plot( cuts.to.PLFN(Sam[,,1]), type="b", col=1, xlim=xlim ) plot( cuts.to.PLFN(Sam[,,2]), type="b", col=2, add=TRUE ) plot( cuts.to.PLFN(Sam[,,3]), type="b", col=3, add=TRUE ) abline( h=round((knot.n+1):0/(knot.n+1),4), lty=3, col="gray70")
This function is able to calculate the Standard of Deviation for a sample with size n from Piecewise Linear Fuzzy Numbers (PLFNs).
Sd(S.PLFN)Sd(S.PLFN)
S.PLFN |
A sample from Piecewise Linear Fuzzy Numbers (PLFNs), with n PLFNs. This sample is an array with |
This function returned a Piecewise Linear Fuzzy Number.
DISTRIB FuzzyNumbers FuzzyNumbers.Ext.2 Calculator.LR.FNs
if(!require(FuzzyNumbers)){install.packages("FuzzyNumbers")} library(FuzzyNumbers) n=3; knot.n=4 Sample <- S.PLFN( n, knot.n, X.dist="norm", X.dist.par=c(3,2), slX.dist="exp", slX.dist.par=3, srX.dist="beta", srX.dist.par=c(1,3) ) Sample # For plotting random fuzzy sample: xlim = c(0, max(Sample[knot.n+2,2,])) plot( cuts.to.PLFN(Sample[,,1]), type="b", xlim=xlim ) plot( cuts.to.PLFN(Sample[,,2]), type="b", add=TRUE ) plot( cuts.to.PLFN(Sample[,,3]), type="b", add=TRUE ) abline( h=round((knot.n+1):0/(knot.n+1),4), lty=3, col="gray70") plot(Mean(Sample), col=4, lwd=2, add=TRUE, type="b") plot(Var(Sample), col=3, lwd=2, add=TRUE, type="b") S = Sd(Sample) S PLFN.to.cuts(S, knot.n) plot(S, col=2, lwd=2, add=TRUE, type="b")if(!require(FuzzyNumbers)){install.packages("FuzzyNumbers")} library(FuzzyNumbers) n=3; knot.n=4 Sample <- S.PLFN( n, knot.n, X.dist="norm", X.dist.par=c(3,2), slX.dist="exp", slX.dist.par=3, srX.dist="beta", srX.dist.par=c(1,3) ) Sample # For plotting random fuzzy sample: xlim = c(0, max(Sample[knot.n+2,2,])) plot( cuts.to.PLFN(Sample[,,1]), type="b", xlim=xlim ) plot( cuts.to.PLFN(Sample[,,2]), type="b", add=TRUE ) plot( cuts.to.PLFN(Sample[,,3]), type="b", add=TRUE ) abline( h=round((knot.n+1):0/(knot.n+1),4), lty=3, col="gray70") plot(Mean(Sample), col=4, lwd=2, add=TRUE, type="b") plot(Var(Sample), col=3, lwd=2, add=TRUE, type="b") S = Sd(Sample) S PLFN.to.cuts(S, knot.n) plot(S, col=2, lwd=2, add=TRUE, type="b")
This function is able to calculate the summation of a sample from Piecewise Linear Fuzzy Numbers (PLFNs).
Sum(S.PLFN)Sum(S.PLFN)
S.PLFN |
A sample from Piecewise Linear Fuzzy Numbers (PLFNs), with n PLFNs. This sample is an array with |
This function returned a Piecewise Linear Fuzzy Number.
DISTRIB FuzzyNumbers FuzzyNumbers.Ext.2 Calculator.LR.FNs
if(!require(FuzzyNumbers)){install.packages("FuzzyNumbers")} library(FuzzyNumbers) n=3; knot.n=4 Sample <- S.PLFN( n, knot.n, X.dist="pois", X.dist.par=5, slX.dist="exp", slX.dist.par=3, srX.dist="beta", srX.dist.par=c(1,3) ) Sample S = Sum(Sample) # For plotting random fuzzy sample: xlim = c(min(Sample[knot.n+2,1,]),S["a4"]) plot( cuts.to.PLFN(Sample[,,1]), type="o", xlim=xlim ) plot( cuts.to.PLFN(Sample[,,2]), type="o", add=TRUE ) plot( cuts.to.PLFN(Sample[,,3]), type="o", add=TRUE ) abline( h=round((knot.n+1):0/(knot.n+1),4), lty=3, col="gray70") plot( S, type="b", add=TRUE, col=2, lwd=3 )if(!require(FuzzyNumbers)){install.packages("FuzzyNumbers")} library(FuzzyNumbers) n=3; knot.n=4 Sample <- S.PLFN( n, knot.n, X.dist="pois", X.dist.par=5, slX.dist="exp", slX.dist.par=3, srX.dist="beta", srX.dist.par=c(1,3) ) Sample S = Sum(Sample) # For plotting random fuzzy sample: xlim = c(min(Sample[knot.n+2,1,]),S["a4"]) plot( cuts.to.PLFN(Sample[,,1]), type="o", xlim=xlim ) plot( cuts.to.PLFN(Sample[,,2]), type="o", add=TRUE ) plot( cuts.to.PLFN(Sample[,,3]), type="o", add=TRUE ) abline( h=round((knot.n+1):0/(knot.n+1),4), lty=3, col="gray70") plot( S, type="b", add=TRUE, col=2, lwd=3 )
This function can simulation from a truncated distribution which is used for generating the left and right spreads of Piecewise Linear Fuzzy Numbers (PLFNs).
Trunc(n, T.dist, T.dist.par, L = -Inf, R = Inf)Trunc(n, T.dist, T.dist.par, L = -Inf, R = Inf)
n |
The sample size. |
T.dist |
The distribution name of random variable (which one needs its truncated version) is determined by characteristic element |
T.dist.par |
A vector of distribution parameters (which one needs its truncated version) with considered ordering in |
L |
The left point of truncation of distribution. |
R |
The right point of truncation of distribution. |
The goal of introducing Trunc function in this package is only using in PLFN and S.PLFN functions.
A vector of random data from the considered truncated distribution.
DISTRIB
# Truncated Normal Distribution: data1 = Trunc(n=10^4, T.dist="norm", T.dist.par=c(5,2), L=3, R=10) hist(data1) data2 = Trunc(n=1000, T.dist="chisq", T.dist.par=4, L=0, R=12) hist(data2) data3 = Trunc(n=10^4, T.dist="norm", T.dist.par=c(5,2), L=3) hist(data3)# Truncated Normal Distribution: data1 = Trunc(n=10^4, T.dist="norm", T.dist.par=c(5,2), L=3, R=10) hist(data1) data2 = Trunc(n=1000, T.dist="chisq", T.dist.par=4, L=0, R=12) hist(data2) data3 = Trunc(n=10^4, T.dist="norm", T.dist.par=c(5,2), L=3) hist(data3)
This function is able to calculate the variance of a sample with size n from Piecewise Linear Fuzzy Numbers (PLFNs).
Var(S.PLFN)Var(S.PLFN)
S.PLFN |
A sample from Piecewise Linear Fuzzy Numbers (PLFNs), with n PLFNs. This sample is an array with |
This function returned a Piecewise Linear Fuzzy Number as the variance of PLFNs.
DISTRIB FuzzyNumbers FuzzyNumbers.Ext.2 Calculator.LR.FNs
if(!require(FuzzyNumbers)){install.packages("FuzzyNumbers")} library(FuzzyNumbers) n=3; knot.n=4 Sample <- S.PLFN( n, knot.n, X.dist="norm", X.dist.par=c(3,2), slX.dist="exp", slX.dist.par=3, srX.dist="beta", srX.dist.par=c(1,3) ) Sample # For plotting random fuzzy sample: xlim = c( min(Sample), max(Sample) ) plot( cuts.to.PLFN(Sample[,,1]), type="o", xlim=xlim ) plot( cuts.to.PLFN(Sample[,,2]), type="o", add=TRUE ) plot( cuts.to.PLFN(Sample[,,3]), type="o", add=TRUE ) abline( h=round((knot.n+1):0/(knot.n+1),4), lty=3, col="gray70") plot(Mean(Sample), col=4, lwd=2, add=TRUE, type="b", pch=2) S2 = Var(Sample) S2 PLFN.to.cuts(S2, knot.n) plot(S2, col=2, lwd=2, add=TRUE, type="b", pch=3)if(!require(FuzzyNumbers)){install.packages("FuzzyNumbers")} library(FuzzyNumbers) n=3; knot.n=4 Sample <- S.PLFN( n, knot.n, X.dist="norm", X.dist.par=c(3,2), slX.dist="exp", slX.dist.par=3, srX.dist="beta", srX.dist.par=c(1,3) ) Sample # For plotting random fuzzy sample: xlim = c( min(Sample), max(Sample) ) plot( cuts.to.PLFN(Sample[,,1]), type="o", xlim=xlim ) plot( cuts.to.PLFN(Sample[,,2]), type="o", add=TRUE ) plot( cuts.to.PLFN(Sample[,,3]), type="o", add=TRUE ) abline( h=round((knot.n+1):0/(knot.n+1),4), lty=3, col="gray70") plot(Mean(Sample), col=4, lwd=2, add=TRUE, type="b", pch=2) S2 = Var(Sample) S2 PLFN.to.cuts(S2, knot.n) plot(S2, col=2, lwd=2, add=TRUE, type="b", pch=3)