Suppose you buy a loaf of bread every day for a year, take it home, and weigh it. You suspect that the distribution of weights is more skewed than a normal distribution with the same mean and standard deviation.
To test your suspicion, write a definition for a class named SkewTest
that extends thinkstats.HypothesisTest
and provides two methods:
TestStatistic
should compute the skew of a given sample.RunModel
should simulate the null hypothesis and return simulated data.
To test this class, I'll generate a sample from an actual Gaussian distribution, so the null hypothesis is true.
Now we can make a SkewTest
and compute the observed skewness.
Here's the p-value.
And the distribution of the test statistic under the null hypothesis.
Most of the time the p-value exceeds 5%, so we would conclude that the observed skewness could plausibly be due to random sample.
But let's see how often we get a false positive.
In the long run, the false positive rate is the threshold we used, 5%.