# Valid Usage of Chi Squared Test

I have 2 distributions. One is a population distribution for a type of image. Another is a sample of an undetermined distribution. I want to compare the distributions to see if they are the same (or reject that they are different).

The two distributions I have are 3 dimensional and discrete, but fit within a 28x28x3 array.

To be more specific, my data are greyscale images. 2 of the dimensions are actually spacial dimensions of the image, and 1 is the intensity of the image.

I want to take the first 2 dimensions as coordinates, and then perform a $\chi^2$ test for goodness of fit, taking the intensity of the sample distribution at a given pixel as the observed, and the intensity of the the population distribution at the same pixel as the expected. Then I can conclude on whether the data I have observed are consistent with the distribution I have.

I would use a Kolmogorov–Smirnov Test, but that requires a continuous distribution, and my distributions are not continuous, only my variables are.

So is this a proper usage of the $\chi^2$ test for Goodness of Fit, or do I need to use a different method to compare these distributions?

## 1 Answer

The Chi-Squared goodness of fit test is generally used for counts of categorical variables. Counts are generally more than 0, but here white is encoded as 0. This means that in the expected case, we are dividing by 0, which generates a statistic of infinity. This is because in this test, observing something for which we expect no counts is considered impossible. But in my own circumstance, I want whitespace to be considered a valid value.

Therefore a Chi-Squared goodness of fit test is innappropriate for this problem.