We can check if things match. 
Sometimes we want to know if things match. 
Imagine you have a plan for how things should look. You expect to see a certain number of red apples and green apples. But when you look, you see something different. How do you know if the difference is just luck? 
Karl Pearson made a way to solve this puzzle. It is called the chi-squared test. This test looks at groups of things. It compares what we see to what we expect. We call what we see "observed" numbers. We call what we think should happen "expected" numbers. 
Pearson shared this idea in 1900. It is a big part of modern math. The test works best when we have many items to count. If the groups are very small, scientists use a different test. One such test is called Fisher's exact test.
This math helps in many ways. People use it to study genes in biology. It can even help people read secret codes. It helps us see if two things are linked. For example, it can show if a neighborhood affects a person's job. The test helps us find real patterns in a sea of data.
Imagine you are looking at a large group of people. You want to know if where they live affects their jobs. You might expect that people in different neighborhoods have similar types of work. To find out, you collect data and put it into a table. This table shows how many people have certain jobs in each area. 
To use this test, you first need two sets of numbers. The first set is called the observed frequencies. These are the actual counts you found when you did your study. The second set is called the expected frequencies. These are the counts you would expect to see if there was no connection between the groups. 
This method was created by a mathematician named Karl Pearson. In the 19th century, most scientists assumed data followed a very smooth, normal pattern. However, Pearson noticed that biological data was often skewed or uneven. 
There are many ways to use these types of tests today. Some researchers use a version called Fisher's exact test. This is better when the groups you are counting are very small. 
Even though this test is helpful, it has some limits. It works best when the groups are large and independent. If the groups are too small, the results might not be right. 
The chi-squared test is a fundamental statistical hypothesis test used to analyze categorical data. It is primarily applied to contingency tables, which are grids used to organize data into different categories. Scientists use this test to determine if two categorical variables are independent or if they influence one another. For example, a researcher might use it to see if a person's neighborhood is related to their job type. The test evaluates how likely the observed data is if we assume there is no relationship between the variables. This assumption is known as the null hypothesis. 
To perform the test, a researcher must compare two sets of values: observed frequencies and expected frequencies. Observed frequencies are the actual counts collected from a sample. Expected frequencies are the counts one would anticipate if the null hypothesis were true. The test calculates the difference between these two sets for every category in the table. This difference is squared to ensure all values are positive. These squared differences are then divided by the expected values. Finally, the researcher sums these results to produce a single value called the test statistic. If this statistic is improbably large, the researcher rejects the null hypothesis, suggesting a real relationship exists.
There are different types of chi-squared tests depending on the research goal. Pearson's chi-squared test is the standard version used for testing goodness of fit or independence. It works best when sample sizes are large. If the sample sizes are small, researchers often use Fisher's exact test instead. Another version is the Cochran–Mantel–Haenszel chi-squared test. There is also McNemar's test, which is used for specific tables containing paired observations. Additionally, Yates's correction for continuity can be applied to reduce errors. This correction subtracts 0.5 from the absolute difference between observed and expected values to adjust the final statistic.
Modern statistics owes much of its structure to the work of Karl Pearson. In the 19th century, researchers like Sir George Airy and Mansfield Merriman assumed biological data followed a normal distribution. However, Pearson noticed that many biological observations showed significant skewness. In a series of articles published between 1893 and 1916, he developed the Pearson distribution. This family of continuous probability distributions can model both normal and skewed data. In 1900, Pearson published his paper on the chi-squared test, which became a foundation of modern statistics. His ideas regarding the distribution of the test statistic caused controversy that lasted for 20 years until it was settled by R.A. Fisher in 1922 and 1924.
The test is highly significant in many scientific fields. In bioinformatics, it is used to compare the distribution of gene properties, such as mutation rates or genomic content. Researchers use it to see if certain genes belong to specific categories, like disease genes or essential genes. In the field of cryptanalysis, the test helps compare the distribution of plaintext and decrypted ciphertext. A low chi-squared value in this context indicates that a decryption was likely successful. The test also has specific mathematical applications, such as testing if the variance of a normally distributed population matches a specific value. For instance, in a sample of size 21, an acceptance region for a 5% significance level falls between 9.59 and 34.17.
Despite its utility, the chi-squared test has several important limitations. It requires that all observations are independent, and violating this assumption can lead to misleading conclusions. The test is also very sensitive to sample size. In very large samples, even tiny, trivial differences can appear statistically significant. Conversely, in very small samples, the test may lack the power to detect real associations. It is also important to note that the test only indicates if a relationship exists. It does not measure the strength or practical importance of that relationship. To find the strength, researchers should report effect size measures like Cramér’s V or the contingency coefficient.
Understanding the chi-squared test requires recognizing how it connects to broader statistical concepts. It is a type of nonparametric statistic, meaning it does not assume the data follows a specific distribution like the normal distribution. It also relates to the concept of homogeneity, which tests if proportions are the same across different groups. While the test assumes a continuous distribution can approximate discrete binomial frequencies, this is not perfectly accurate. This is why researchers must be cautious when expected frequencies in any category are very small. Generally, it is recommended that expected frequencies be at least 5 to ensure accuracy. 
🖼️ Images & Media (1)
More to explore
✨ What else?
Related topics you might enjoy
🔬 Go deeper
More advanced topics to explore
🪜 Step back
Simpler topics to build understanding
What is Nepedia?
A free, ad-free encyclopedia for children. Every article is written at five reading levels, so the same page works for a five-year-old and a fifteen-year-old — use the level switcher above to see this one change. No account needed to read.