Gaussian fiting
조회 수: 5 (최근 30일)
이전 댓글 표시
Hello,
I have (X,Y) data and i want to fit this data with a Gaussian. Basically i use 'lsqnonlin' which works fine (if the initial solution X0 is not too bad).
I just have two questions because i don't have a lot of experience with Matlab:
1/ lsqnonlin seems to be an appropriate method (Gaussian = non linear (mu,sigma)) but i find a tool in mathwork which use polyfit ? Do you think Polyfit or other methods would be better than lsqnonlin (regarding to the stability of the final solution and the importance of the initial solution).
2/ I use the folowing definition for Gaussian :
G = A * 1/(sigma*sqrt(2*pi)) * exp(-(1/2)*(X-mu/sigma).^2) + C;
A,mu sigma and C are the variable to estimate.
This allow me to obtain sigma directly. Do you think it's the best way to "express" the Gaussian ?
Thank you very much for your help
댓글 수: 0
채택된 답변
Andrew Newell
2011년 4월 4일
1. Polyfit wouldn't make much sense because a Gaussian is not polynomial and would be badly approximated by polynomials.
2. The normalizer is irrelevant because you are multiplying it by some unknown. Also, since mu is the mean (and therefore determines the horizontal displacement), you could get rid of C. However, you need an extra pair of parentheses:
G = A * exp(-(1/2)*((X-mu)/sigma).^2);
Or you could get rid of mu and keep C:
G = A * exp(-(1/2)*(X/sigma).^2) + C;
Either way, you now only have 3 parameters to fit.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Polynomials에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!