MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Fit Gaussian function to histogram

  • To: mathgroup at smc.vnet.net
  • Subject: [mg117894] Re: Fit Gaussian function to histogram
  • From: Mark Fisher <particlefilter at gmail.com>
  • Date: Sat, 2 Apr 2011 17:05:48 -0500 (EST)
  • References: <imsh9i$5me$1@smc.vnet.net>

On Mar 29, 7:54 am, cubsfan334 <cubsfan... at 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!

Maybe you're interesting in something like this:

data = RandomReal[NormalDistribution[], 100];
histo = Histogram[data, 10, "PDF"];
hdata = Cases[histo,
   RectangleBox[{x0_, _}, {x1_, y_}, _] :> {.5 (x0 + x1),
     y}, \[Infinity]];
fun = PDF[NormalDistribution[m, s], x] /.
   FindFit[hdata, PDF[NormalDistribution[m, s], x], {m, s}, {x}];
Show[histo, Plot[fun, {x, Min[data], Max[data]}]]

--Mark


  • Prev by Date: IndependetVertexSetQ Bug
  • Next by Date: Re: defining a integer greater than one
  • Previous by thread: Re: Fit Gaussian function to histogram
  • Next by thread: Re: Fit Gaussian function to histogram