Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|cite|improve this question
Is this homework? – Simon Hayward Nov 3 '12 at 10:42
At least for me it is not a homework. Another person asked me that. – student Nov 3 '12 at 10:46
Yes, 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. – Simon Hayward Nov 3 '12 at 11:13
The 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, . – student Nov 3 '12 at 11:29
You may want to put your comment here where you found the computation as an answer, so that people see it more readily! – kcrisman Jun 26 '14 at 3:12
up vote 1 down vote accepted

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:-

Some info on goodness of fit with link to further resources is on wikipedia:-

Shout if anything is unclear.

share|cite|improve this answer

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.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.