dist_uniform(min, max)

## Arguments

min lower and upper limits of the distribution. Must be finite. lower and upper limits of the distribution. Must be finite.

## Details

A distribution with constant density on an interval.

We recommend reading this documentation on https://pkg.mitchelloharawild.com/distributional/, where the math will render nicely.

In the following, let $$X$$ be a Poisson random variable with parameter lambda = $$\lambda$$.

Support: $$[a,b]$$

Mean: $$\frac{1}{2}(a+b)$$

Variance: $$\frac{1}{12}(b-a)^2$$

Probability mass function (p.m.f):

$$f(x) = \frac{1}{b-a} for x \in [a,b]$$ $$f(x) = 0 otherwise$$

Cumulative distribution function (c.d.f):

$$F(x) = 0 for x < a$$ $$F(x) = \frac{x - a}{b-a} for x \in [a,b]$$ $$F(x) = 1 for x > b$$

Moment generating function (m.g.f):

$$E(e^{tX}) = \frac{e^{tb} - e^{ta}}{t(b-a)} for t \neq 0$$ $$E(e^{tX}) = 1 for t = 0$$

## Examples

dist <- dist_uniform(min = c(3, -2), max = c(5, 4))

dist
#> <distribution[2]>
#> [1] U(3, 5)  U(-2, 4)mean(dist)
#> [1] 4 1variance(dist)
#> [1] 0.3333333 3.0000000skewness(dist)
#> [1] 0 0kurtosis(dist)
#> [1] -1.2 -1.2
generate(dist, 10)
#> [[1]]
#>  [1] 3.719182 4.310035 3.208588 4.820395 3.247009 3.970001 3.848841 4.413332
#>  [9] 3.614408 4.918179
#>
#> [[2]]
#>  [1] -0.08341130  0.23677863  3.05051087 -0.03648231  3.39143916  1.96795113
#>  [7]  2.38681148 -1.41493439 -0.04912791  2.51548383
#>
density(dist, 2)
#> [1] 0.0000000 0.1666667density(dist, 2, log = TRUE)
#> [1]      -Inf -1.791759
cdf(dist, 4)
#> [1] 0.5 1.0
quantile(dist, 0.7)
#> [1] 4.4 2.2