# How to fit a gaussian curve to data for a goodness-of-fit C++? [duplicate]

I've given a dataset of N samples like: (x,y) (-100,1), (-90, 30), (-50,60), (-10,90), (0,100), (10, 90), (30, 20),(100,4)

Now I would like to determine how well the data fits a perfect gaussian (normal) distribution. For that reason, I want to fit a gaussian curve to the data and in an additional step compare the estimated gaussian with the "perfect" gaussian. Any ideas how to achieve this in C++, Boost or Eigen functions?

I'm quite stuck here. Is this even a good approach? What I actually want is a measure of how well the data follows a gaussian distribution shape.

• Do you want to fit a gaussian curve, or determine whether the data was drawn from a gaussian probability distribution? Jul 22, 2016 at 17:52
• Since I'd like to know how well it follows a perfect gaussian shape I guess it's the latter so: determine whether the data was drawn from a gaussian probability distribution
– Sean M.
Jul 23, 2016 at 7:07
• Many different solutions are possible. Please search our site.
– whuber
Aug 7, 2016 at 20:44