# Getting point estimation and confidence interval for gaussian fit

I have a task where I should fit the data sample with curve_fit and get the peak's position and amplitude. I fitted data and got these values and their standard errors. I also need to find point estimation and confidence interval for position and amplitude.

Can anyone give some hints on how to find them? I've found solutions for a range of values but I don't understand how to apply this information for a single value.

UPD: here's my curve

So, I have the peak's position, amplitude and their error. Now I need to find point estimation and confidence interval. Is there any relation to the standard error?

• Welcome to Cross Validated! Do you mean fitting a bell curve to some two-dimensional points or fitting a Gaussian distribution to one-dimensional data? Both are reasonable tasks, but they are not the same.
– Dave
Nov 24, 2022 at 20:11
• hello! I have 1D data Nov 24, 2022 at 20:15
• Hi! Can you show us some details? What kind of curve fitting are considering? Nov 24, 2022 at 20:19
• @utobi uploaded code and fit params Nov 24, 2022 at 20:24
• I'm not very familiar with python, but is your curve $f(x) = ae^{(x-x_0)^2/(2d^2)}+c$ ? Nov 24, 2022 at 20:53

I am not very familiar with python but looking at the documentation, I see that curve_fit delivers both the parameter estimates and their covariance.

Thus once you run it and if the optimization goes fine, you should have the estimates $$\hat a, \hat x_0, \hat c, \hat d$$ and their standard errors.

Using calculus you can check that the maximum of the function $$f(x) = ae^{-(x-x_0)^2/(2d^2)}+c$$ is at $$x=x_0$$; thus with the observed data, the maximum is reached at $$\hat x_0$$.

To obtain inference for $$x_0$$, you may: (a) use an asymptotic result or (b) use the bootstrap.

Option (a)

Assuming the nonlinear least squares estimator is consistent and asymptotically normal, then $$\hat x_0\, \dot\sim\,\, N(x_0, \text{se}(x_0)^2).$$

An approximate 95% confidence interval for $$x_0$$ is then $$\hat x_0 \pm 1.96 \text{se}(x_0)$$.

Option (b)

Get the bootstrap distribution of $$\hat x_0$$ and build a confidence interval through the equal-tail interval. In particular, assuming the sample size is $$n$$, for $$b = 1,\ldots, B$$ (say $$B=10^5$$), do:

• sample $$n$$ rows with replacement from your data, call this sampled dataset $$y^*_b$$;
• fit the curve to get $$\hat x_{0,b}^*$$.

Use the list $$\hat x_{0,1}^*,\ldots,\hat x_{0,B}^*$$, i.e. the bootstrap sample taken from the distribution of $$\hat x_0$$, to compute $$\hat x_{0,0.025}^*$$ the 0.025th sample quantile and $$\hat x_{0,0.975}^*$$ the 0.975th sample quantile. A 95% confidence interval is then

$$[\hat x_{0,0.025}^*,\hat x_{0,0.975}^*].$$

Note that this is only the easiest way to compute the bootstrap interval but it's not necessarily the most accurate. If you want to go deeper in this respect check Davison & Hinkley (1997) Bootstrap Methods and Applications, Cambridge University Press.

• thanks for such thorough answer Nov 24, 2022 at 21:49