Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is the purpose of goodness of fit evaluation in data science?
Goodness of fit evaluation checks how well a statistical model matches observed data. It helps us see if the model explains the data well or if it misses important patterns.
Click to reveal answer
beginner
Which Python library provides tools for goodness of fit tests like Chi-square and Kolmogorov-Smirnov?
The scipy.stats module offers functions like chisquare() and kstest() to perform goodness of fit tests.
Click to reveal answer
beginner
What does a low p-value in a goodness of fit test indicate?
A low p-value means the model does not fit the data well. It suggests the observed data is unlikely if the model were true, so we might reject the model.
Click to reveal answer
intermediate
Explain the Chi-square goodness of fit test in simple terms.
The Chi-square test compares observed counts in categories to expected counts from a model. It measures if differences are too big to be just chance.
Click to reveal answer
intermediate
What is the Kolmogorov-Smirnov test used for in goodness of fit?
The Kolmogorov-Smirnov test compares the shape of the observed data distribution to a theoretical distribution to see if they match closely.
Click to reveal answer
Which function in scipy.stats is used for the Chi-square goodness of fit test?
Apearsonr()
Bkstest()
Cttest_ind()
Dchisquare()
✗ Incorrect
The chisquare() function performs the Chi-square goodness of fit test.
What does a high p-value in a goodness of fit test suggest?
ATest is invalid
BModel does not fit data
CModel fits data well
DData is random
✗ Incorrect
A high p-value means we do not reject the model; it fits the data well.
Which test compares the cumulative distribution of data to a theoretical distribution?
AKolmogorov-Smirnov test
BChi-square test
CANOVA
DLinear regression
✗ Incorrect
The Kolmogorov-Smirnov test compares cumulative distributions.
In goodness of fit, what are 'expected counts'?
AObserved data values
BPredicted counts from the model
CRandom numbers
DTest statistics
✗ Incorrect
Expected counts are what the model predicts for each category.
Which scipy.stats function would you use to test if data fits a normal distribution?
Akstest()
Bchisquare()
Cttest_rel()
Dwilcoxon()
✗ Incorrect
kstest() can test if data fits a specified distribution like normal.
Describe how you would use scipy to check if your data fits a theoretical distribution.
Think about comparing observed data to expected or theoretical distribution.
You got /3 concepts.
Explain the difference between the Chi-square test and the Kolmogorov-Smirnov test for goodness of fit.
Focus on what each test measures and the data format.
You got /3 concepts.
Practice
(1/5)
1. What does the chi-square goodness of fit test in scipy.stats.chisquare primarily evaluate?
easy
A. The mean difference between two samples
B. How well observed data matches expected frequencies
C. The correlation between two variables
D. The variance within a single dataset
Solution
Step 1: Understand the purpose of chi-square test
The chi-square goodness of fit test compares observed data frequencies to expected frequencies to check if they match.
Step 2: Identify what scipy.stats.chisquare does
This function calculates the chi-square statistic and p-value to evaluate the fit between observed and expected counts.
Final Answer:
How well observed data matches expected frequencies -> Option B
Quick Check:
Goodness of fit = observed vs expected match [OK]
Hint: Chi-square tests observed vs expected frequencies [OK]
Common Mistakes:
Confusing goodness of fit with correlation
Thinking it measures mean differences
Mixing variance analysis with goodness of fit
2. Which of the following is the correct way to import the chi-square goodness of fit test function from scipy?
easy
A. import scipy.chisquare
B. from scipy import chisquare
C. from scipy.stats import chisquare
D. import scipy.stats.chisquare as cs
Solution
Step 1: Recall the module structure of scipy
The chi-square test function is inside the stats submodule of scipy.
Step 2: Identify correct import syntax
The correct import is from scipy.stats import chisquare to directly access the function.
Final Answer:
from scipy.stats import chisquare -> Option C
Quick Check:
Correct import = from scipy.stats import chisquare [OK]
Hint: Import from scipy.stats for statistical tests [OK]
Using scipy.stats.chisquare with these values gives a p-value around 0.368, indicating moderate fit.
Final Answer:
2.0 0.368 -> Option A
Quick Check:
Chi-square stat = 2.0, p-value ≈ 0.368 [OK]
Hint: Calculate chi-square stat then check p-value [OK]
Common Mistakes:
Forgetting to square differences
Dividing by wrong expected values
Mixing up statistic and p-value
4. Identify the error in this code snippet for performing a chi-square goodness of fit test:
from scipy.stats import chisquare
observed = [15, 25, 35]
expected = [20, 20]
result = chisquare(f_obs=observed, f_exp=expected)
print(result)
medium
A. Observed and expected arrays have different lengths
B. chisquare function is not imported correctly
C. Expected frequencies must be integers
D. Missing p-value extraction from result
Solution
Step 1: Check input array lengths
The observed array has 3 elements, but expected has only 2 elements, which is invalid for chi-square test.
Step 2: Understand scipy requirement
Both observed and expected arrays must be the same length to compare frequencies correctly.
Final Answer:
Observed and expected arrays have different lengths -> Option A
Quick Check:
Array length mismatch causes error [OK]
Hint: Observed and expected must be same length [OK]
Common Mistakes:
Ignoring length mismatch
Assuming expected must be integers
Thinking import or print is the error
5. You have observed counts of [40, 35, 25] for three categories. You expect them to be equally likely. Using scipy.stats.chisquare, what is the p-value indicating if the observed data fits the equal distribution? (Hint: expected counts are equal for all categories.)
hard
A. 0.789
B. 0.223
C. 0.456
D. 0.174
Solution
Step 1: Calculate expected counts for equal distribution