Skip to main content

Posts

Showing posts with the label NumPy

Featured Post

The Making of a Dumb Datum

Imagine 10,000 years in the future. Two archaeologists are digging a site, and they find the remains of human bones. They take those remains to the lab, perform tests on them, and try to reconstruct the habits and lifestyle of that human. Say those bones belong to me. They are trying to find out my story, how I lived, what I ate, where I traveled, etc. Once they find all the info they need, they toss it into a museum where they store all other such ancient human remains they find. I was essentially one data point to them in trying to understand how humanity evolved over time. Or I can also call myself a “datum”, the singular form of data, literally one piece of information to solve a bigger puzzle. Honestly, I don’t need 10,000 years to become a datum. I am already a part of several datasets people use these days to study many things. So for that objective learner, I am already a datum. Now let me get to how I got the dumb part of it. I have had an interesting and eventful life so far...

The quirk of NumPy!

 

Unravelling the secret behind numpy.std!

  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.