>   restart:
read `C:\\Tanis-Hogg\\Maple Examples\\stat.m`:

Elliot Tanis
April 20, 2006
Exercise 5.3-6 (Exercise_5_3-6.mws)

Exercise 5.3-6 and some additional links for the Cauchy distribution.

>   f := CauchyPDF(x);

f := 1/(Pi*(1+x^2))

>   for k from 1 to 9 do
    w := Pi*rng() - Pi/2:
    XX[k] := evalf(tan(w)):
  od:
  X := [seq(XX[k], k = 1 .. 9)];

X := [-4.980135731, 4.964487081, -.7981338995, -.2110610261, 6.228548187, -1.969067060, -2.872019381, .1411003782e-1, -4.734943281]
X := [-4.980135731, 4.964487081, -.7981338995, -.2110610261, 6.228548187, -1.969067060, -2.872019381, .1411003782e-1, -4.734943281]

>   Mean(X);

-.4842461192

>   X := sort(X);

X := [-4.980135731, -4.734943281, -2.872019381, -1.969067060, -.7981338995, -.2110610261, .1411003782e-1, 4.964487081, 6.228548187]
X := [-4.980135731, -4.734943281, -2.872019381, -1.969067060, -.7981338995, -.2110610261, .1411003782e-1, 4.964487081, 6.228548187]

>   Median(X);

-.7981338995

(c) Here is a simulation of 1000 observations of a Cauchy random variable.

>   numgt1 := 0:  # number greater than 1
numgt5 := 0:  # number greater than 5
numgt10 := 0: # number greater than 10
for k from 1 to 1000 do
  w := Pi*rng() - Pi/2:
  X := evalf(tan(w)):
  if X > 1 then numgt1 := numgt1 + 1 fi:
  if X > 5 then numgt5 := numgt5 + 1 fi:
  if X > 10 then numgt10 := numgt10 + 1 fi:
od:

>   numgt1;
evalf(numgt1/1000);
evalf(int(f, x = 1 .. infinity));

254

.2540000000

.2500000000

>   numgt5;
evalf(numgt5/1000);
evalf(int(f, x = 5 .. infinity));

61

.6100000000e-1

.6283295825e-1

>   numgt10;
evalf(numgt10/1000);
evalf(int(f, x = 10 .. infinity));

30

.3000000000e-1

.3172551759e-1

>   

If you want to see additional simulations for the Cauchy distribution, click on the following link.

Additional Cauchy simulations

Return to Menu