# Chi square test of homogeneity for histogram comparison

I have two algorithms that simulate some process. The result of each algorithm run is a histogram of proportions of produced simulated entities, where each bin represents one type of objects. I need to compare the "average histograms" (per bin average proportions over multiple algorithm runs) for both algorithms in order to reason about their equivalence. I believe the chi square test of homogeneity is one possibility. However, while the counts/proportions across the two histograms are independent (one algorithm does not affect the other), the counts within groups are not (completely) independent. For instance, the entities being counted interact in a simulation so a higher count of one type of entity may result in a lower count of another type of entity. In short, the intra-group independence assumption does not hold. My question is whether the chi square test of homogeneity is still applicable in this case and, if not, what other test should I use to compare the histograms. Should I instead use some kind of multiple paired t-test (one test per bin), which would also account for the variance?

## 1 Answer

You need a Multinomial test.

This is the test of the null hypothesis that the parameters of a multinomial distribution equal specified values.

The multinomial distribution models the probability of counts for a fixed number of independent trials each of which leads to a success for exactly one of a fixed number of categories. With each category having a given fixed success probability, the multinomial distribution gives the probability of any particular combination of numbers of successes for the various categories.

(Above text is freely adopted from Wikipedia.)

PS. Do you really need a quantitative rejection of the null hypothesis? Repeat your simulations very often and then plot the differences between them per bin. Maybe all doubts vanish already.