added averages.pyx which uses cython to calculate state averages.