I'm having an inordinate amount of trouble understanding how to fit a gaussian curve to my peak. There are some similar questions but even after looking at these I'm still not sure. Statistics/probability theory etc were never my strong point but I think what confuses me is the gaussian bell curve is calculated simply using the mean and standard deviation. The actual raw values in the peak are not used unlike other curve fitting methods.
Ive implemented the gaussian function thus;
public static float getGaussian(float x, float mean, float stdDev)
{
float v1 = 1F / (stdDev * (float)Math.Sqrt(2 * Math.PI));
float v2 = ((x - mean) * (x - mean)) / (2 * (stdDev * stdDev));
return (v1 * (float)Math.Exp(-v2));
}
I think this is correct but my "curve" ends up looking like a flat plain so Im obviously doing something wrong.
The raw data ie the (x,y) points are
(9,0) (10,1) (11,2) (12,3) (13,4) (14,10) (15,12) (16,13) (17,23) (18,26) (19,23) (20,20) (21,17) (22,12) (23,5) (24,3) (25,3) (26,4) (27,2) (28,2) (29,1)
Can anyone explain how the gaussian curve should be calculated from this data and what the curve will look like?



