1
$\begingroup$

Observe the following code:

p = 0.5; n = 10^2;
XbarObservationSet = Mean[RandomVariate[GeometricDistribution[p], {n, n}]]
myplot1 = ?????
myplot2 = Plot[PDF[NormalDistribution[0, 1], x], {x, -3, 3}]
Show[myplot1, myplot2]

Suppose my goal is to take all of the data collected in XbarObservationSet and display an approximated, continuous probability density function corresponding to the observed data and then compare it to a typical normal distribution. In other words, I want to see the continuous PDF approximation of the 100 instances of the estimator Xbar that I have collected. How can I do this? How would I define myplot1?

$\endgroup$
  • 1
    $\begingroup$ Would you elaborate as to why you use {n, n} rather than something like {n, 100n}? With just 100 simulations of the mean of 100 samples you're not going to get a very good estimate (let alone a good estimate from a secondary continuous approximation). With a much larger sample size (say '100 n = 10,000`) then all 3 of the answers below will work fine and you'll see that the distribution of the mean of 100 samples is approximately normal (i.e., the Central Limit Theorem kicks in). $\endgroup$ – JimB Feb 17 '18 at 5:17
1
$\begingroup$
Show[Histogram[XbarObservationSet, 20],
 Plot[PDF[
   NormalDistribution[Mean[XbarObservationSet], 
    StandardDeviation[XbarObservationSet]], x], {x, 0, 1.5}]]

enter image description here

(I don't know why you expect your sample would be well fit by a Gaussian centered on $0$.)

$\endgroup$
  • 2
    $\begingroup$ To have Histogram match the PDF in the plot you should use Histogram[XbarObservationSet, 20, "PDF"]. Otherwise the vertical axis for Histogram is counts and probability density for the Plot. $\endgroup$ – JimB Feb 17 '18 at 5:06
1
$\begingroup$
p = 1/2; n = 10^2;
SeedRandom[0];
ObservationSet = RandomVariate[GeometricDistribution[p], {n, n}];
XbarObservationSet = 
  Mean[RandomVariate[GeometricDistribution[p], {n, n}]];

To find the NormalDistribution that best fits the data use EstimatedDistribution

dist = EstimatedDistribution[XbarObservationSet, 
  NormalDistribution[m, s]]

(* NormalDistribution[0.9936, 0.132087] *)

Show[
 Histogram[XbarObservationSet, 10, "PDF"],
 Plot[PDF[dist, x], {x, Min[XbarObservationSet], 
   Max[XbarObservationSet]}]]

enter image description here

$\endgroup$
0
$\begingroup$

You can use SmoothKernelDistribution for that

p = 0.5; n = 10^2;
XbarObservationSet = 
  Mean[RandomVariate[GeometricDistribution[p], {n, n}]];

Plot[{PDF[SmoothKernelDistribution[XbarObservationSet], x], 
  PDF[NormalDistribution[0, 1], x]}, {x, -3, 3}, PlotRange -> All]

Mathematica graphics

Although I'm not sure if you rather would like to see something like this:

Plot[{PDF[SmoothKernelDistribution[XbarObservationSet], x], 
  PDF[NormalDistribution[Mean[XbarObservationSet], 
    StandardDeviation[XbarObservationSet]], x]}, {x, 0, 2}, 
 PlotRange -> All]

Mathematica graphics

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.