unidistr | R Documentation |
The function takes in a vector "X"" against which it returns a vector with a uniform distribution, given the other boundary parameters "a" and "b".
unidistr(X, a, b)
x |
Describes the (numeric) vector against which you need the uniformly distributed vector |
a |
Describes the lower bound of X below which the function returns a zero value |
b |
Describes the upper bound of X above which the function returns a zero value |
1. The lower bound should be LESS THAN(NOT EQUAL TO)the upper bound.
2. If a is NOT less than b, function throws an error(careful using constrained optimization).
The returned value is always a numeric vector.
1. Unlike the "gauss(X, sig,...)" function, the function does not have a probability term.
2. a equal to b makes no sense since then the entire function collapses to something like a Dirac delta function.
Chitran Ghosal
X <- seq(-10, 10, by= 0.05)
Y1 <- unidistr(X, a = -1, b = 1)
Y2 <- unidistr(X, a = -0.5, b = 0.6)
Y3 <- unidistr(X, a = -0.2, b = 0.4)
plot(X, Y3, type='l', col=rgb(0,0,1, 0.5))
lines(X, Y2, type = 'l', col=rgb(0,1,0, 0.5))
lines(X, Y1, type = 'l', col=rgb(1,0,0, 0.5))
legend(x='topleft', legend = c('Y3', 'Y2', 'Y1'), fill = c(rgb(0,0,1, 0.5), rgb(0,1,0, 0.5), rgb(1,0,0, 0.5)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.