Simulation

We will now simulate some data from an F distribution in order to compare the sampling distribution to the theoretical distribution. The next bit of code will simulate a random sample of size 500 from an F(7, 10) distribution, but you are encourage to change the parameters [Maple Math] and [Maple Math] .

> restart: with(plots):

> nu[1]:=7: nu[2]:=10: n:=500:

> sample:=FS(nu[1],nu[2],n):

Remember that when you plot histograms, the number of bins that you select can make a huge difference in the plot.

> num_bins:=26:

> a:=Histogram(sample,0..13,num_bins):

> b:=plot(FPDF(nu[1],nu[2],x),x=0..13,color=black):

> display([a,b],title="Simulated vs. Theoretical");

[Maple Plot]

Now let's compare the simulated mean to the theoretical mean.

> theo_mean:=nu[2]/(nu[2]-2);

[Maple Math]

> sim_mean:=Mean(sample);

[Maple Math]

> relative_error:=(sim_mean-theo_mean)/theo_mean;

[Maple Math]

>