Is the "real" Standard Deviation different?


#1



https://www.codecademy.com/en/courses/python-intermediate-en-7mgOa/2/3?curriculum_id=4f89dab3d788890003000096


There are no errors in my code. I think Codecademy may be using the wrong formula when calculating the standard deviation. I'm not 100% sure so input would be appreciated. I'm sure there's some small reason as to why the formula codecademy is using is correct but I'm just not able to catch it. Here's a picture of the formula I see in youtube exercises
Imgur


When looking up tutorials of how to calculate the standard deviation, i noticed that the actual formula had an extra bit of info that the exercise doesn't have (n-1). n =Sample size, which is the same as len(scores) in the code. Anyone have an explanation of why we aren't removing 1 item like the formula asks? Thanks.



def grades_variance(scores):
    average = grades_average(scores)
    variance = 0
    for score in scores:
        variance += (score - average)**2
    variance = variance / len(scores) # the confusion is here. i think there should be an extra -1 as this only calculates "n"  
    return variance


#2

When you have "N" data values that are:

    The Population: divide by N when calculating Variance
    A Sample: divide by N-1 when calculating Variance

http://www.mathsisfun.com/data/standard-deviation.html

In our case, we are dealing with all the marks, so population. Had we a larger set of data and only took a sample from that, then we subtract 1 from n (the sample size).


#3

That answers everything perfectly! Thanks for the reply!


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.