Data Analysis

One of the first things you will be asked to do in a computational lab is often: “Read this column of data and tell me the mean and variance.”. This is a superbly simple task given the right tools. Suppose you have a column of data in the file “data.dat”, you can save the following simple python script in a file named “col.py” in the same directory and run with the terminal command python col.py or chmod +x col.py; ./col.py. The second set of commands will only work if an interpreter is specified at the first line with “#!”. Even without this line python col.py will still work.

#!/usr/bin/env python2.7
import numpy as np
data = np.loadtxt("data.dat")
print data.mean(),data.std()**2

If this is the first program you have ever written, then congratulation! You have just avoided the horrendously useless “hello world” introduction and have actually done something useful! Anyways, enough with the baby steps. Let’s fly!

Level 1 Mean and Standard Error
Level 2 Compare and Combine Statistical Data
Level 3 Curve Fitting and Extrapolation
Level 4 Bootstrap for Error of Fit