I have been given a set of data points. How can I find the best fit of the form $\frac{1}{\sqrt{2\pi}\sigma}e^{-\frac{(x-\mu)^2}{\sigma^2}}?$ Even better if Sage can do it. And how can I approximate how good the fit is?
Fitting normal distribution to the data
-
0You may want to put your comment here where you found the computation as an answer, so that people see it more readily! – 2014-06-26
2 Answers
The best fit is given by finding the sample mean $\overline{x}$ and putting this in place of the population mean $\mu$ in the distribution function. Then you find the sample variance $\hat{s}^2$ and substitute for $\sigma^2$ in the distribution function.
You can then use the $\chi^2$ goodness of fit test to determine whether the fit is a good one or not.
I wouldn't know about doing this in Sage, although there is a tutorial here:-
http://www.sagemath.org/doc/reference/sage/gsl/probability_distribution.html
Some info on goodness of fit with link to further resources is on wikipedia:-
https://en.wikipedia.org/wiki/Goodness_of_fit
Shout if anything is unclear.
I think the good point to start is Normality test where you can find few approaches to test the data Graphical methods, Back-of-the-envelope test, Frequentist testsBayesian tests.
I assume that Sage should have package with Shapiro-Wilk Test for Normality.