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
-
0Is this homework? – 2012-11-03
-
0At least for me it is not a homework. Another person asked me that. – 2012-11-03
-
0Yes, it is because this seems like a very common homework question, which is absolutely fine, just that it should be marked as such if it is. – 2012-11-03
-
1The original author wanted to find a software to do such fitting. I found the question interesting as I had never met such a problem. But now I learned that I can use $\chi^2$-test to measure how good solution is and found that Sage will do the job for me, http://ask.sagemath.org/question/1164/gauss-distribution-fit . – 2012-11-03
-
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.