MathGroup Archive 2003

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

Search the Archive

Re: Histogram normalization

The ``smoothed histogram'' you are looking for is
replicated by the nonparametric density. I think you
might find the NonParametricDensity function below
useful. It is a very simplified version  without
control over the kernels etc. but it should do the

The code defines the nonparametric density, creates a
500 point sample from a t_4 distribution, and plots
the ``smooth histogram'' of the sample together with
the t_4.

(* Copy into .nb                                   *)
<< "Statistics`ContinuousDistributions`"

NonParametricDensity[x_] := Module[{sx, g, gg, T, h}, 
    sx = StandardDeviation[x]; T = Length[x]; 
     h = (sx*1.06)/T^0.2; g = Function[{u}, 
       (1*Plus @@ (Exp[-((u - #1)^2/(2*h^2))] & ) /@
        (T*h*Sqrt[2*Pi])]; FunctionInterpolation[g[u],

      {u, Min[x] - 4*h, Max[x] + 4*h}]]; 

dist = StudentTDistribution[4]; 
Y = RandomArray[dist, 500]; 
NPf = NonParametricDensity[Y]; 

Plot[{PDF[dist, x], NPf[x]}, {x, -5, 5}, Frame ->
   Axes -> False, PlotStyle -> {Thickness[0.], 


Kyriakos Chourdakis

Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts

  • Prev by Date: Re: How to apply one plot range to another plot?
  • Next by Date: Re: Right-click'd BMP vs. exported BMP
  • Previous by thread: Re: Histogram normalization
  • Next by thread: Re: Re: Histogram normalization