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


Groups > comp.soft-sys.math.mathematica > #1432 > unrolled thread

Re: Fit Gaussian function to histogram

Started byMark Fisher <particlefilter@gmail.com>
First post2011-04-02 22:05 +0000
Last post2011-04-02 22:05 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Fit Gaussian function to histogram Mark Fisher <particlefilter@gmail.com> - 2011-04-02 22:05 +0000

#1432 — Re: Fit Gaussian function to histogram

FromMark Fisher <particlefilter@gmail.com>
Date2011-04-02 22:05 +0000
SubjectRe: Fit Gaussian function to histogram
Message-ID<in86jl$9tr$1@smc.vnet.net>
On Mar 29, 7:54 am, cubsfan334 <cubsfan...@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

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web