Create a ddf object for the discrete uniform distribution on the first
\(n\) natural numbers (including or excluding 0).
Details
The discrete uniform distribution describes models in which a finite number of possible outcomes are equally likely to happen. In general, it has an arbitrary finite set, say of cardinality \(N\in\mathbb{N}\), as its support with every element of the support having the same probability \(\frac{1}{N}\).
This function, however, only generates the uniform distribution on support
\(\{1, \dots, n\}\) or \(\{0, \dots, n\}\). For more complicated supports,
it's expected to be much easier to simply use ddf() without specifying
probabilities, rather than using a custom function like this one.
For a demonstration of this, see also the ‘Examples’ below.
See also
Other distributions:
benford(),
bernoulli(),
beta_binomial(),
bin(),
geometric(),
hypergeometric(),
negative_bin(),
negative_hypergeometric(),
pois(),
rademacher(),
zipf()
Examples
# Probability distribution for modelling a
# six-sided dice (uniform on {1, ..., 6})
unif(6)
#> Discrete uniform distribution on {1, ..., 6}
#>
#> Support:
#> [1] 1 2 3 4 5 6
#>
#> Probabilities:
#> [1] 0.1666667 0.1666667 0.1666667 0.1666667 0.1666667 0.1666667
# For more complicated supports, use ddf
# Same distribution as above (except for description):
ddf(1:6)
#> A discrete distribution with finite support
#>
#> Support:
#> [1] 1 2 3 4 5 6
#>
#> Probabilities:
#> [1] 0.1666667 0.1666667 0.1666667 0.1666667 0.1666667 0.1666667
# Not possible using unif:
ddf(seq(3, 12, 3))
#> A discrete distribution with finite support
#>
#> Support:
#> [1] 3 6 9 12
#>
#> Probabilities:
#> [1] 0.25 0.25 0.25 0.25
