File Exchange

image thumbnail

Gaussian fit

version 1.5.0.0 (2.15 KB) by Przemyslaw Baranski
Fits Gaussian curve into points. The curve is understood as a probability density function, pdf.

25 Downloads

Updated 23 Feb 2012

View License

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

Comments and Ratings (12)

R

R (view profile)

VoyageR

VoyageR

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

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

Eddie (view profile)

Thijs

Thijs (view profile)

Updating my previous comment for future readers.

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

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.

Updates

1.5.0.0

Checking if the input points (x,y) are sorted. If not sort them. Improved checking if p.d.f sums up to 1

1.4.0.0

Normalization of data. Added some infos to the helpd section

1.1.0.0

More description, so that it can perhaps be easier found

MATLAB Release Compatibility
Created with R2007b
Compatible with any release
Platform Compatibility
Windows macOS Linux

MATLAB Online Live Editor Challenge

View the winning live scripts from faculty and students who participated in the recent challenge.

Learn more

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video