Skip to main content

Beta distribution

The beta distribution is a flexible distribution useful for modelling things between 00 and 11 - like frequencies, proportions, or probabilities.

Challenge

Pick 'shape' parameters α\alpha and β\beta (make them between 1 and 10 to start) and plot the beta distribution:

x∣α,β∼1B(α,β)xα−1(1−x)β−1x | \alpha,\beta \sim \frac{1}{B(\alpha,\beta)} x^{\alpha-1} (1-x)^{\beta-1}

over the (continuous) range x=0⋯1x=0 \cdots 1.

Note. The beta distribution is implemented as dbeta() in R, but you have to use "shape1" and "shape2" instead of α\alpha and β\beta:

dbeta( x, shape1 = alpha, shape2 = beta )

How does the shape vary as you change the parameters? What happens if they are less than 1?

Expert challeng

For extra kudos, ignore dbeta() and write your own function beta_distribution() to compute this based on the normal distributino density formula:

x∣α,β∼1B(α,β)x(α−1)⋅(1−x)(β−1)x | \alpha, \beta \sim \frac{1}{B(\alpha,\beta)} x^{(\alpha-1)} \cdot (1-x)^{(\beta-1)}

(You can use the beta() function to compute the value B(α,β)B(\alpha,\beta) on the demoninator.)

Cumulative and quantiles​

Just like the normal and binomial, the beta distribution has cumulative desnity pbeta() and quantile function qbeta().

For example, 95% of the mass of a beta(1,1)\text{beta}(1,1) distribution is between:

qbeta( c( 0.025, 0.975 ), 1, 1 )

(Hmm - these values look familiar. Why?)