fuzzyfun: Fuzzy version of a function

View source: R/fuzzyfun.R

fuzzyfunR Documentation

Fuzzy version of a function

Description

It computes the fuzzy version of a function applied to a fuzzy number x of class fzn or a fuzzy array of class fzarray.

Usage

fuzzyfun(x,
                fun,
                n = 1001,
                ...)

Arguments

x

A fuzzy number of class fzn or a fuzzy array of class fzarray.

fun

A string with the function name.

n

Number of subintervals for finding optimal values in the non-monotone case.

...

Other arguments for function fun.

Value

A fuzzy number of class fzn or a fuzzy array of class fzarray.

Examples

x <- fzn(alpha = c(0, 1), l = c(0, 1), u = c(2, 1))
par(mfrow = c(2, 2))
plotfzn(x, main = "Triangular x")
y <- fuzzyfun(x, fun = "sqrt")
plotfzn(y, main = "sqrt(x)")
x2 <- fzn(alphacut(x, alpha = seq( from = 0, to = 1, by = 0.1)))
plotfzn(x2, main = "x with extra alpha-cuts")
y2 <- fuzzyfun(x2, fun = "sqrt")
plotfzn(y2, main = "sqrt(x)")

x <- fzn(alpha = c(0, 1), l = c(-1, 0), u = c(1, 0))
x <- fzn(alphacut(x, alpha = seq( from = 0, to = 1, by = 0.1)))
plotfzn(x, main = "Triangular x")
z <- fuzzyfun(fuzzyfun(x, fun = "abs"), fun = "sqrt")
plotfzn(z, main = "sqrt(abs(x))")
xx <- x * x
plotfzn(xx, main = "x * x")
x2 <- fuzzyfun(x, fun = "^", y = 2) # It is not the same!
plotfzn(x2, main = "x ^ 2")

x <- seq(from = 0, to = 2 * pi, length.out = 101)
fzt <- fzn(alpha = c(0, 1), l = c(-0.5, 0), u = c(0.5, 0))
fzx1 <- x + fzt
fzy1 <- fuzzyfun(fzx1, fun = "^", y = 2)
fzx2 <- x + fzn(alphacut(fzt, alpha = c(0, 0.25, 0.5, 0.75, 1)))
fzy2 <- fuzzyfun(fzx2, fun = "^", y = 2)
fy1b <- fuzzyfun(fzx2, fun = "sin")
plotfzn(x = x, y = fzx1)
plotfzn(x = x, y = fzy1)
plotfzn(x = x, y = fzy2)
plotfzn(x = x, y = fy1b)


rbensua/fuzzyr documentation built on May 20, 2023, 7:11 a.m.