Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2012

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

Search the Archive

Re: histospline

  • To: mathgroup at smc.vnet.net
  • Subject: [mg126308] Re: histospline
  • From: Bob Hanlon <hanlonr357 at gmail.com>
  • Date: Mon, 30 Apr 2012 04:41:17 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201204290611.CAA10877@smc.vnet.net>

Not sure if this is what you want but it may help.

Clear[compare]

compare::usage =
  "compare[data, dist] plots PDF of maximum likelihood estimate with \
histogram scaled as PDF.";

compare[data_,
   dist_: NormalDistribution[Unique[], Unique[]]] :=
  Module[
   {estDist =
     EstimatedDistribution[data, dist]},
   Show[
    Histogram[data, Automatic, "PDF",
     ChartStyle -> EdgeForm[None]],
    Plot[PDF[estDist, x],
     {x, Min[data], Max[data]},
     PlotStyle -> Darker[Red]],
    Frame -> True,
    Axes -> False,
    PlotLabel -> "Data Histogram and " <> ToString[estDist]]];

dist1 = NormalDistribution[5*RandomReal[], 2*RandomReal[]]

data1 = RandomVariate[dist1, 200];

compare[data1] (* defaults to NormalDistribution *)

dist2 = GammaDistribution[4*RandomReal[] + 1, 2*RandomReal[]]

data2 = RandomVariate[dist2, 300];

compare[data2, GammaDistribution[a, b]]


Bob Hanlon


On Sun, Apr 29, 2012 at 2:11 AM, paul <paulvonhippel at yahoo.com> wrote:
> I'm looking for a Mathematica package that can generate a histospline.
> This is a smooth density estimate based only on the information in a histogram.
>



  • References:
  • Prev by Date: Mathematica NB file to LaTeX for publication?
  • Next by Date: Re: Trouble plotting BSpline
  • Previous by thread: histospline
  • Next by thread: NDSolve in 3D