Mean without outliers
Description:
The mean and standard deviation of a sample of data can be thrown off if the sample contains one or many outlier(s) :
For this reason, it is usually a good idea to check for and remove outliers before computing the mean or the standard deviation of a sample. To this aim, your function will receive a list of numbers representing a sample
of data. Your function must remove any outliers and return the mean of the sample
, rounded to two decimal places (round only at the end).
Since there is no objective definition of "outlier" in statistics, your function will also receive a cutoff
, in standard deviation units. So for example if the cutoff is 3, then any value that is more than 3 standard deviations above or below the mean must be removed. Notice that, once outlying values are removed in a first "sweep", other less extreme values may then "become" outliers, that you'll have to remove as well!
Example :
sample = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 100]
cutoff = 3
clean_mean(sample, cutoff) → 5.5
Formula for the mean :
Formula for the standard deviation :
Note : since we are not computing the sample standard deviation for inferential purposes, the denominator is n, not n - 1.
Similar Kata:
Stats:
Created | Jul 10, 2017 |
Published | Jul 10, 2017 |
Warriors Trained | 1571 |
Total Skips | 75 |
Total Code Submissions | 10555 |
Total Times Completed | 775 |
Python Completions | 671 |
R Completions | 117 |
Total Stars | 60 |
% of votes with a positive feedback rating | 92% of 106 |
Total "Very Satisfied" Votes | 90 |
Total "Somewhat Satisfied" Votes | 15 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 7 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 6 kyu |