dist_uniform(min, max)We recommend reading this documentation on pkgdown which renders math nicely. https://pkg.mitchelloharawild.com/distributional/reference/dist_uniform.html
In the following, let \(X\) be a Uniform random variable with parameters
min = \(a\) and max = \(b\).
Support: \([a, b]\)
Mean: \(\frac{a + b}{2}\)
Variance: \(\frac{(b - a)^2}{12}\)
Probability density function (p.d.f):
$$ f(x) = \frac{1}{b - a} $$
for \(x \in [a, b]\), and \(f(x) = 0\) otherwise.
Cumulative distribution function (c.d.f):
$$ F(x) = \frac{x - a}{b - a} $$
for \(x \in [a, b]\), with \(F(x) = 0\) for \(x < a\) and \(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\), and \(E(e^{tX}) = 1\) for \(t = 0\).
Skewness: \(0\)
Excess Kurtosis: \(-\frac{6}{5}\)
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 1
variance(dist)
#> [1] 0.3333333 3.0000000
skewness(dist)
#> [1] 0 0
kurtosis(dist)
#> [1] -1.2 -1.2
generate(dist, 10)
#> [[1]]
#> [1] 4.412863 3.110841 3.294262 4.843539 3.536916 4.706541 3.579131 3.558930
#> [9] 4.141509 3.598392
#>
#> [[2]]
#> [1] 2.7762149 0.7081251 3.2308620 -0.3270352 2.2782224 0.4127122
#> [7] 3.7797287 2.7310516 0.2768036 3.9653013
#>
density(dist, 2)
#> [1] 0.0000000 0.1666667
density(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