unidistr: returns a vector with a uniform distribution aginst the input...

View source: R/unidistr.R

unidistrR Documentation

returns a vector with a uniform distribution aginst the input vector X

Description

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".

Usage

unidistr(X, a, b)

Arguments

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

Details

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).

Value

The returned value is always a numeric vector.

Note

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.

Author(s)

Chitran Ghosal

Examples

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)))

Chitran1987/StatsChitran documentation built on Feb. 23, 2025, 8:30 p.m.