Beta Distribution Explorer

By RaphT, Feb 2015





Try out the explorer here

The Beta Distribution Family

The Beta distribution is a family of distributions:

  • Continuously defined in the [0,1] interval
  • Controlled by two positive shape parameters alpha and beta
  • Used to model random variables limited to a finite length interval

plot of chunk unnamed-chunk-1

Examples of beta distribution

Explorer work flow

  1. Simulates a beta distribution based on a set of parameters
  2. Uses Betareg to fit alpha and beta on the simulated distribution
  3. Displays the distribution and the theoretical and fitted density functions
alpha = 2; beta = 3; dist = data.frame(x = rbeta(100, alpha, beta))
model = betareg(x~., link = "logit", link.phi = "log", data = dist)
ggplot(dist, aes(x=x)) + geom_histogram(aes(y=..density..), breaks=seq(0,1,by=0.011))+
  stat_function(fun=dbeta, args=list(shape1=alpha, shape2 = beta),col = "red")+
  stat_function(fun=dbeta, args=list(shape1=alpha.fitted, shape2 = beta.fitted),col = "green")

plot of chunk unnamed-chunk-5

Explorer Options

Interactively change the value of alpha and beta via sliders

Interactively change the number of samples in the distribution

Choose the standard or alternative parametrization of the distribution

   1. The standard directly uses alpha and beta

   2. The alternative uses mu (location) and phi (dispersion)

Future work

Add the possibility to open and fit custom data set





Acknowledgments

This webpage helped me get the two columns to work