I know you could recite the formula for sample standard deviation even in your sleep.
That (n-1) in the denominator inside the square root must be no stranger to you.
There’s a good chance you already know that a sample has n-1 degrees of freedom, which is why we use it in the denominator instead of a straightforward “n.”
It is a no-brainer that using the .std() function to calculate the standard deviation for a NumPy array is a piece of cake for you.
But if you haven’t heard about the “ddof” parameter in this function yet, let me caution you against using the .std() directly to calculate sample standard deviations.
This parameter accounts for the degree of freedom while calculating standard deviation, and its default value is zero.
If you aren’t setting it to “1”, you are calculating population standard deviation instead of the sample statistic.
Hence, always cross-check that you are setting the appropriate value to the ddof parameter while using the .std function.
Comments
Post a Comment