Chi Square Formula
Chi square formula is used to compare two or more statistical data sets. The chi square formula is used in data that consist of variables distributed across various categories, and helps us to know whether that distribution is different from what one would expect by chance.
Example: You research two groups of women and put them in categories of student, employed or selfemployed.
Group 1  Group 2  
Student  40  30 
Employed  89  67 
Selfemployed  3  7 
The numbers collected are different, but you now want to know
 Is that just a random occurence? Or
 Is there any correlation?
What is the Chi Square Formula?
The chisquared test checks the difference between the observed value and expected value. The chisquare formula is:
χ^{2} = ∑(O_{i} – E_{i})^{2}/E_{i}
where O_{i} = observed value (actual value) and E_{i }= expected value.
Finding Pvalue
The ChiSquare test gives a Pvalue to help you know the correlation if any!
A hypothesis is in consideration, that a given condition or statement might be true, which we can test later. For example
 A very small ChiSquare test statistic indicates that the collected data matches the expected data extremely well.
 A very large ChiSquare test statistic indicates that the data does not match very well. If the chisquare value is large, the null hypothesis is rejected.
ChiSquare test statistic is called Pvalue. The Pvalue is short for probability value. It defines the probability of getting a result that is either the same or more extreme than the other actual observations. The Pvalue represents the probability of occurrence of the given event. The Pvalue is used as an alternative to the rejection point to provide the least significance for which the null hypothesis would be rejected. The smaller the Pvalue, the stronger is the evidence in favor of the alternative hypothesis given observed frequency and expected frequency.
Pvalue  Description  Hypothesis Interpretation  
Pvalue ≤ 0.05 

Rejected  
Pvalue > 0.05 

Accepted or it “fails to reject”.  
Pvalue > 0.05  The Pvalue is near the cutoff. It is considered as marginal  The hypothesis needs more attention. 
Solved Examples on Chi Square Formula

Example 1:
Calculate the Chisquare value for the following data of incidences of waterborne diseases in three tropical regions.
Solution: Setting up the following table:
Answer: Chi Square = 125.516 
Example 2:
What conclusion should be made with respect to an experiment when the significance level is 0.05 (p = 0.05)?
Solution:
Since the pvalue of 0.068 is greater than 0.05, it would fail to reject the null hypothesis.
Answer: As the value of p < 0.05, the null hypothesis is rejected.