MathGroup Archive 1999

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

Search the Archive

Gaussian PDF Overlay

  • To: mathgroup at smc.vnet.net
  • Subject: [mg19277] Gaussian PDF Overlay
  • From: Lawrence Walker <lwalker701 at earthlink.net>
  • Date: Thu, 12 Aug 1999 01:24:28 -0400
  • Organization: Morgan State University: COMSARE
  • Sender: owner-wri-mathgroup at wolfram.com

I've tried to overlay a continuous gaussian probability
density curve onto a bar chart of similar distribution.  The
values for the barchart were generated by bin counting the
data using the BinCounts function.  The data is a list
generated by Random[NormalDistribution[]].

At first I simply tried to overlay the plot and barchart
using Show.  The x-axis scale of the curve was different
from the 
barchart's scale.  So I had to manually change the position
and rescale the curve until it overlayed the barchart using
the program below.  I didn't like the fact that the x-scale
shows 0 to 40 instead of -4 to 4.

Is there a better way of doing this?


<<Statistics`NormalDistribution`;
<<Graphics`Graphics`;
<<Statistics`DataManipulation`;

gauss:=Random[NormalDistribution[]];
data=Table[gauss,{7000}];
cutoffs=Range[-4,4,.2];
freq=BinCounts[data,{-4,4,.2}];
midpts=Drop[cutoffs+.1,-1];

bchart=BarChart[Transpose[{freq,midpts}],PlotRange->All
,BarLabels->None,
    DisplayFunction->Identity];


PlotCharts[mu_,sigma_,scale_]:=(
    plt=Plot[Evaluate[scale    
PDF[NormalDistribution[mu,sigma],x]],{x,0,40},
        PlotRange->All,DisplayFunction->Identity];
    Show[plt,bchart,DisplayFunction->$DisplayFunction]);

PlotCharts[20.5,5,7300]		

Thanks,
Lawrence

-- 


------------------------------------------------------------
     (\___/)     The fear of the LORD is the beginning of    
     (o\ /o)     wisdom: a good understanding have all they  
    /|:.V.:|\    that do his commandments: his praise        
    \\::::://    endureth for ever.              Psa 111:10  
-----`"" ""`------------------------------------------------
        Lawrence A. Walker Jr., M.Eng./Ph.D. Candidate      
                   Morgan State University                  
          Clarence M. Mitchell School of Engineering        
 COMSARE (Center Of Microwave/Satellite And RF Engineering) 
           Rm: 306-Schafer     Phone: (443)885-1453        
------------------------------------------------------------


  • Prev by Date: Re: ListPlot question
  • Next by Date: Re: Element Extraction
  • Previous by thread: Re: Defining a function P[A_ | B_]:=f[A,B] overriding Alternatives
  • Next by thread: Re: Gaussian PDF Overlay