Finding sigma from fit using Curve Toolbox gaussian?
조회 수: 30 (최근 30일)
이전 댓글 표시
I am using the gaussin fitting functions in the Matlab curve fitting toolbox, which uses the model:
ans(x) = a1*exp(-((x-b1)/c1)^2) + a2*exp(-((x-b2)/c2)^2)
This all works well for my data and I get the fits, but now I want to know what sigma is for these two gaussians? That isn't just c, is it? Can someone tells me how the fit coefficients relate to sigma?
Much appreciation.
Gary
댓글 수: 0
답변 (1개)
Shashank Prasanna
2013년 1월 22일
편집: Shashank Prasanna
2013년 1월 22일
If you look at the gaussian equation the curve fitting toolbox fits:
you will notice that it is different from the standard normal/gaussian distribution equation given here:
which means you can equate the coefficients you can equate them and get the value of sigma.
a1 = 1/sigma*sqrt(2*pi)
-1/c^2 = -1/2*sigma^2
댓글 수: 1
Fynn Reinbacher
2020년 11월 5일
sigma = 1/(a*sqrt(2*pi));
Has to be used with caution.
This works only for normalized datasets.
In the matlab version of the gaussian:
For nomalized data
and the above answer is indeed valid
In order to get σ from a you'd need to integrate your data first
% if:
[x, cnts] = load('mydata.mat'); % data you are fitting
f1 = fit(x, cnts, 'gauss1');
% then:
mu = f1.b1;
sigma = f1.c1/sqrt(2);
% or:
intergral = trapz(x, cnts);
sigma = integral/(f.a1*sqrt(2*pi));
This has me bugged for a long time.
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!