Create a score based on how evenly 5 groups are distributed I have 5 buckets of age ranges: Age Less than 25 years, Age 25-34 years, Age 35-44 years, Age 45-54 years, Age 55 years and more
I want a formula to create a score based on how evenly the 5 groups are distributed. For example if there are the same number of people in each of the 5 buckets I want the score to be 100 and if only 1 of the 5 buckets has people in it (worst distribution) I want the score to be zero or one.
 A: A commonly used statistic to measure how well $n$ observations from
a categorical variable fit a discrete uniform distribution on five levels of
the variable is
$$Q = \sum_{i=1}^5 \frac{(X_i - E_i)^2}{E_i},$$
where the $X_i$ are the observed counts at each level, and the $E_i$
are the expected counts if the distribution is discrete uniform
distribution. In your case $E_i = n(1/5).$
Under the null hypothesis $H_0$ that the levels are equally likely,
$Q \stackrel{aprx}{\sim} \mathsf{Chisq}(df = 4).$
If $n=50,$ then $E_i \equiv 10.$ If it happens that $X_i \equiv 10,$
then $Q = 0.$ If it happens that $X_1 = 50$ and $X_2 = X_3 = X_4 = X_5 = 0,$
then $Q = 200.$ So the $Q$-scale works in the opposite direction to what
you want: 0 for a good fit to uniform and large for a bad fit to uniform.
However, using the P-value of the test, one gets something like what you
want. The P-value is the probability (under $H_0$) of getting a larger 
value of $Q$ than observed. Then the P-value is 1 for a perfect fit ($Q=0$) and
0 for $Q = 200.$  [Computations in R statistical software below.]
 1 - pchisq(0, 4)
 ## 1
 1 - pchisq(200, 4)
 ## 0

So the P-value of the 'goodness-of-fit' test, performs somewhat as you described. If all $X_i > 0$ without having all $X_i = 50,$ then the P-value may be small, but not round to $0.0$. [For example, if the counts are $X=(8,8,8,8,18),$ then
$Q = 8$ and the P-value is $.092 \ne 0.$]
Although perhaps not exactly what you want, I chose to explore the P-value of the goodness-of-fit (GOF)
statistic $Q$ because GOF methods are widely used in statistics.
However, there are many different methods of measuring 'diversity' of
a sample. (See the Wikipedia article on 'diversity index' to look at
some of them.)
