Is this a good batch of stout? (Student's t test)
Description:
You have been hired by a large stout brewery in order to improve the quality testing of their beer. Your superiors want you to devise a way of determining whether a batch of beer is likely to be good enough for sale using a small sample of beers from this batch. Luckily for you, a smart Englishman found a solution to this problem a bit more than a hundred years ago...
Your task in this kata is to implement a function to do Student's one-sample t-test. In the current problem, you will be testing for alcohol content. Your function will receive :
- A list of the alcohol content of each beer in a sample of beers :
sample
- A target alcohol content :
pop_mean
- A probability threshold :
alpha
By calculating a t value for the sample, you will be able to determine whether the current batch is likely to have an average alcohol content close to the target, or not. In statistical terms, if the likelihood that the current sample of beers was taken from the population of beers with a mean of pop_mean
(the target alcohol content) is too small (it is too different from the "average" sample), then the whole batch will be rejected.
Specifically, your solution will calculate a t statistic (formula below) and compare it to a "critical" t value, corresponding to the threshold. You are given a table of critical t values (t_table
), containing only positive values of t (the t distribution is symmetrical) which you may access like so : t_table[degrees_of_freedom - 1][probability]
. Degrees of freedom in a one sample t-test are equal to n - 1, where n is the sample size. If the sample's t value is greater than the "critical" t value (and therefore less probable), then your function will return "Reject". Else, your function will return "Good to drink". All samples will range in size from 2 to 20.
Formula for the t statistic :
Formula for the sample standard deviation (s) :
Kata inspired by this.
Similar Kata:
Stats:
Created | Jul 6, 2017 |
Published | Jul 6, 2017 |
Warriors Trained | 304 |
Total Skips | 3 |
Total Code Submissions | 2602 |
Total Times Completed | 134 |
Python Completions | 134 |
Total Stars | 19 |
% of votes with a positive feedback rating | 86% of 29 |
Total "Very Satisfied" Votes | 22 |
Total "Somewhat Satisfied" Votes | 6 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 5 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 6 kyu |