File Exchange

Gaussian fit

version 1.5.0.0 (2.15 KB) by Przemyslaw Baranski

Przemyslaw Baranski (view profile)

Fits Gaussian curve into points. The curve is understood as a probability density function, pdf.

Updated 23 Feb 2012

The function fits Guassian probability density function into a set of points. Standard deviation and mean are returned.

Cite As

Przemyslaw Baranski (2020). Gaussian fit (https://www.mathworks.com/matlabcentral/fileexchange/35122-gaussian-fit), MATLAB Central File Exchange. Retrieved .

R

VoyageR

VoyageR

VoyageR (view profile)

Data is not normalized! The pdf sums to: 0.000000. Normalizing...

Undefined function 'exp' for input
arguments of type 'uint8'.

Error in gaussfit (line 89)
dfdsigma =
-1/(sqrt(2*pi)*sigma^2)*exp(-((x-mu).^2)
/ (2*sigma^2));

How to normalize my data ?

John TB

John TB (view profile)

Good and helpful routine for 1D Gaussian fitting!

any

any (view profile)

Hi,I have a problem with this program...Data is not normalized! The pdf sums to: 0.454068. Normalizing...
What is the problem???
Thank you...

Georges

sr

sr (view profile)

My data has a constant (with some spread) y-offset. Please let me know what to do in your code to make it fit? Thanks

sr

sr (view profile)

My data has a constant (with some spread) y-offset. Please let me know what to do in your code to make it fit? Thanks

Eddie

Thijs

Thijs (view profile)

Updating my previous comment for future readers.

The problem was indeed incorrectly scaled data. The function works quite beautifully now.

Przemyslaw Baranski

Przemyslaw Baranski (view profile)

Hi Thijs. Is your data properly scaled? I mean a probability density function should sum up to 1 and so should roughly the histogram for which your try to fit the curve

Thijs

Thijs (view profile)

I changed the line 88 from exit to return.

The function works rather poorly on my data though, I get better results minimizing the logarithmic residuals.