
Sample Beta Distribution and Return Density
beta_dist.RdGenerates a beta distribution based on a specified mean and variance, and returns a density estimate as a data frame.
Arguments
- mean
Numeric scalar. Desired mean of the beta distribution. Must be between 0 and 1 (exclusive).
- variance
Numeric scalar. Desired variance of the beta distribution. Will be constrained by
variance_factor.- samples
Integer. Number of samples to draw from the beta distribution. Default is 1000.
- variance_factor
Numeric scalar. Limits the allowed variance as a fraction of the theoretical maximum variance. Default is 0.1.
Value
A tibble with columns x and y representing the smoothed density estimate of the sampled beta distribution.
Details
The shape (i.e., skew and peak) of a Beta distribution is driven by the ratio alpha / (alpha + beta) (which controls the mean), and the sum alpha + beta (which controls the concentration/peakedness).
Examples
beta_dist(mean = 0.4, variance = 0.01)
#> # A tibble: 512 × 2
#> x y
#> <dbl> <dbl>
#> 1 0.0891 0.000358
#> 2 0.0905 0.000431
#> 3 0.0918 0.000517
#> 4 0.0931 0.000620
#> 5 0.0944 0.000743
#> 6 0.0957 0.000886
#> 7 0.0971 0.00105
#> 8 0.0984 0.00124
#> 9 0.0997 0.00147
#> 10 0.101 0.00174
#> # ℹ 502 more rows