modification nov 8 2014, sinusoidal basis, normal gradient, before changing ellipse representation to mean and covariance