Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #1276

Re: Fit Gaussian function to histogram

From Barrie Stokes <Barrie.Stokes@newcastle.edu.au>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Fit Gaussian function to histogram
Date 2011-03-30 09:14 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <imusa2$i5s$1@smc.vnet.net> (permalink)

Show all headers | View raw


Hi

The first thing I would do would be to find m=Mean[ data ] and sd=StandardDeviation[ data ], and then plot together the histogram and something like

Plot[ PDF[ NormalDistribution[ m, sd  ], x ], {x, Min [data ], Max[ data] ],

and see if the Gaussian is at all a reasonable fit.

Fitting distributions to data is a big area, and there are tests for closeness of fit. Have a look through the Mathematica documentation.

There is

DistributionFitTest[ data, Automatic, "HypothesisTestData" ] in the documentation for DistributionFitTest.

(I found this by searching the online documentation for "Kolmogorov", because I know that the Kolmogorov-Smirnov test is such a test.)

Have a look also at AndersonDarlingTest[].

If you enter "fitting Normal distribution to data" into the search box for the online documentation, the second screen will lead you to

FindDistributionParameters[], and it will mention also EstimatedDistribution[].

Mathematica can give you a lot of power to attack a problem like this. There is a lot of example code in these documentation pages, too.

Cheers

Barrie

>>> On 29/03/2011 at 10:54 pm, in message <201103291154.GAA05840@smc.vnet.net>,
cubsfan334 <cubsfan334@gmail.com> wrote:
> Hi,
> 
> I realize that I can generate a histogram from a data set using the
> Histogram[{data},bin size] command, yet this only seems to create a
> graphic.  Is there anyway to fit a function (preferably Gaussian) to
> the histogram Mathematica creates?
> 
> Thanks!

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: Fit Gaussian function to histogram Barrie Stokes <Barrie.Stokes@newcastle.edu.au> - 2011-03-30 09:14 +0000

csiph-web