Artificial intelligent assistant

Probability distribution for sum of squared differences of randomly distributed marbles Suppose I have $n$ buckets and $m$ marbles, where $m >> n$, and I randomly put marbles in buckets Each marble has a $1/n$ chance of being put in each bucket. At the end of the process, bucket $i$ has $m_i$ marbles for $1 \leq i \leq n$. As a function of $n$ and $m$, what would be the probability distribution of $$ \sum_{i=1}^n \left( m_i - \frac{m}{n} \right)^2 $$ If there's some more interesting quantity for measuring "even-ness" of distribution (maybe with a simpler PDF expression), I'd be even more interested in that! PS: This came up as I was trying to write some tests automatically checking how "fair" bucketing functions are

I don't think there is a usable formula for the exact distribution of your quantity, but $n/m$ times your quantity has approximately a chi squared distribution on $n-1$ degrees of freedom. (After multiplication by $n/m$ your quantity is the Pearson chi squared test statistic, so a lot is known about it.) If $m/n\to\infty$ and also $n\to\infty$, you can probably use a normal approximation to this chi squared distribution.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 8f9a37398418ca580d63bf27b038d333