Mandel's k for one of a set of \(g\) standard deviations \(s\) is calculated as
$$k=\frac{s_{ij}^2}{\sum_{i=1}^p{s_{ij}^2/p}}$$
Since the numerator is chi-squared(n-1), or Gamma((n-1)/2, 2), and the denominator
can be written as the sum of the same quantity and a pooled variance with distribution
Gamma((g-1)*(n-1)/2, 2), k is distributed as Beta((n-1)/2, (g-1)(n-1)/2).
Quantiles, probabilities, density and random numbers can therefore be generated
from the Beta distribution. For example, qmandelk is calculated as
sqrt( g * qbeta( (n-1)/2, (g-1)*(n-1)/2))
.