Jose Drost-Lopez

Calculating Sample Variance in Python

In Personal on April 23, 2011 at 5:21 am

I am taking a break from my usual psychology antics to share some statistics-related code with the world. I wrote this Python program using standard libraries (no stats libraries) to verify that using (n-1) instead of (n) to calculate sample variance is a better long-run estimator of population variance. I’m quite sure both the code and the math is sloppy: let me know so I can refine it!

http://dl.dropbox.com/u/17834939/SampleVariance.py

(Originally, I tried pasting the code in, but I got ugly extra line breaks, so I’ve linked to the text file above).

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: