Galton board: balls stacked in columns of different height
Photo by Alisson Ricardo, exhibit made by MockUp Company, from Wikimedia Commons, CC BY-SA 4.0, cropped

Data Science Fundamentals

Chi-Square Goodness of Fit

Observed and expected counts
Value Observed Expected (O − E)² / E

Press Test.

How it works

The parameter of the distribution is estimated from the sample: the mean for the Poisson law, the mean divided by the largest value for the binomial law, 1 / (1 + mean) for the geometric law. The expected count of a value is its probability times the size of the sample. The statistic χ² adds up (O − E)² / E: the larger it is, the worse the fit. The p-value is the probability of such a statistic or a larger one when the sample does follow the distribution; below 0.05 the distribution is rejected. The number of degrees of freedom is the number of values minus one, as in the chisq.test call of my work.

From the course

  • Semester 6
  • Practical assignment 3: distribution fitting
  • Written in R
  • The samples on this page are made up

Useful resources

  1. Goodness of fit the article from the Wikipedia