Test Survey Results with Chi-Square
Advanced · Write the code · from SciPy Statistics: Distributions, Hypothesis Tests, and Correlations
From the lesson: SciPy Statistics: Distributions, Hypothesis Tests, and Correlations
A pharmaceutical company develops a new headache medicine. They give it to 100 patients and a placebo to another 100. The treatment group reports slightly fewer headaches. But is that difference real, or just random chance? This is the question statistics answers.
Read the lessonA survey asked 200 people to choose their favorite season. The results were: Spring=60, Summer=70, Fall=45, Winter=25. If there were no preference, each season would get 50 votes. Use scipy.stats.chisquare() to test whether the distribution is uniform. Print the chi-square statistic (rounded to 1 decimal) and whether preferences are 'Significant' or 'Not significant' at alpha=0.05.
More SciPy Statistics exercises
- Compute Descriptive StatisticsAdvanced
- Work with the Normal DistributionAdvanced
- Run an A/B Test with a T-TestAdvanced
- Calculate and Interpret CorrelationAdvanced
- Compute a Confidence IntervalAdvanced
All Python exercises · 50 practice problems · Data Science & Machine Learning quiz