06-02 Random Discrete Data
06-02 Random Discrete Data
You can change the Objective To show how to create a binomial sample by doing a Bernoulli
experiment n times. This simulation takes 50 samples for whatever
parameters! Try it! Press F9 to take a new sample. binomial parameters you specify. Each time you press F9 you will see
50 random numbers from your binomial distribution. Observe the
Parameters Statistic Theory Sample Diff sample statistics and histograms to see if they resemble the theoretical
n 10 Mean 1.000 1.060 -0.060 values.
p 0.10 St. Dev. 0.949 0.998 -0.049
Note The histogram scales are always set to 0 to 20. This may not show enough
Note Differences of 10% or detail for some values of n and p.
more are highlighted.
Random Data
Sample Successes
1 0
Histogram of 50 Binomial Samples Binomial Distribution Being Sampled
2 2
3 2
4 0
Relative Frequency
0.40 0.40
5 1
Probability
6 2 0.30 0.30
7 3 0.20
0.20
8 2
0.10 0.10
9 1
10 0 0.00 0.00
11 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
12 1 Number of Successes Number of Successes
13 4
14 0
15 0 Suggested Exercises (1) Press F9 five times and record the mean and Binomial Distribution
standard deviation of each sample of 50. What is the largest deviation
16 0
from the theoretical values m =np and s = [np(1-p)]0.5? (2) Compare
17 0 your histogram of 50 binomial samples to the theoretical distribution. As Parameters n = number of trials
18 0 you press F9 five more times, how often do your sample histograms look = probability of success
19 1 similar to the theoretical distribution? How often do they differ a lot? (3)
20 0 If we were to increase the number of samples to 100 instead of 50, what Probability function n!
effect would you anticipate on the answers to questions (1) and (2)? Why P( x) x (1 ) n x
21 0 x!(n x)!
22 1 do we only do 50?
23 0 Range X = 0, 1, 2, ..., n where X is the number of
24 0 Methodology Excel's function =BINOM.INV(n, p, RAND()) will
successes in n trials
25 1 generate a binomial random variate. Alternatively, we can set up a
26 2
Mean n
Bernoulli experiment using your p and repeat it n times, to get a
27 0 binomial sample in which X = number of successes in n trials (illustrated
28 1 at right). To get 50 such binomial deviates, we repeat the whole process
29 2 50 times. This is rather cumbersome, but it works. St. Dev. n(1 )
30 1
31 1
32 0 Skewness 1 2
33 1 n(1 )
34 1
35 1 Kurtosis 6 1
36 3 3
n n(1 )
37 1
38 1 Comments Always symmetric if = .50 and
39 1 approaches symmetry for any as n
40 1
increases. Normal approximation is
41 1
42 0 acceptable if n 10 and n(1 ) 10.
43 2 #NAME?
Random Number Generation - Poisson
You can change l! Try it! Objective To show how to create a Poisson sample. This simulation
Press F9 to take a new sample. takes 50 samples for a specified l in the range 0.01 < l 10. Each Histogram Bins Sample Poisson
time you press F9 you will see 50 random numbers from your Lower Upper f f/50 P(X)
Parameters Statistic Theory Sample Diff Poisson distribution. Observe the sample statistics and histograms to 0 0.99 0 0.0000 0.0067
Mean 5.000 4.920 0.080 see if they resemble the theoretical values. 1 1.99 2 0.0400 0.0337
l 5
St. Dev. 2.236 2.127 0.109 2 2.99 2 0.0400 0.0842
Note The histogram scales are always set to 0 to 20. This may not 3 3.99 12 0.2400 0.1404
Note Differences of 10% or 4 4.99 6 0.1200 0.1755
show enough detail for some values of l.
more are highlighted.
Random Data 5 5.99 6 0.1200 0.1755
Sample Arrivals 6 6.99 14 0.2800 0.1462
1 4 7 7.99 3 0.0600 0.1044
Histogram of 50 Poisson Samples Poisson Distribution Being Sampled
2 7 8 8.99 3 0.0600 0.0653
3 6 9 9.99 1 0.0200 0.0363
0.30 0.30
4 3 10 10.99 0 0.0000 0.0181
Ralative Frequency
0.25 0.25
5 8 11 11.99 0 0.0000 0.0082
Probability
0.20 0.20
6 3 0.15 0.15 12 12.99 1 0.0200 0.0034
7 3 0.10 0.10 13 13.99 0 0.0000 0.0013
8 7 0.05 0.05 14 14.99 0 0.0000 0.0005
9 8 0.00 0.00 15 15.99 0 0.0000 0.0002
-0.05 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 -0.05 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
10 6 16 16.99 0 0.0000 0.0000
11 5 17 17.99 0 0.0000 0.0000
12 2 Number of Arrivals Number of Arrivals 18 18.99 0 0.0000 0.0000
13 5 19 19.99 0 0.0000 0.0000
14 1 20 20.99 0 0.0000 0.0000
15 1 Suggested Exercises (1) Press F9 five times and record the mean and Total 50 1.0000 1.0000
16 9 standard deviation of each sample of 50. What is the largest deviation Methodology Excel offers no function to generate a Poisson
17 2 from the theoretical values m =l and s = l0.5? (2) Compare your random variate. However, if F(x) is the cumulative Poisson
18 3 histogram of 50 binomial samples to the theoretical distribution. As you distribution from Excel, we can choose a unit random decimal R.
press F9 five more times, how often do your sample histograms look Systematically try all x in the range of X. If F(x-1) R < F(x)
19 4 then the Poisson random variable is x. To get 50 such binomial
20 6 similar to the theoretical distribution? How often do they differ a lot? (3)
If we were to increase the number of samples to 100 instead of 50, what deviates, we repeat the whole process 50 times. This is rather
21 3 cumbersome, but it works. See Merran Evans, Nicholas Hastings,
effect would you anticipate on the answers to questions (1) and (2)? Why
22 6 do we only do 50? and Brian Peacock, Statistical Distributions, 3rd Edition (Wiley,
23 6 2000), p. 160.
24 4
25 5
26 3
27 5 Poisson Distribution
28 6
29 3 Parameters = mean arrivals per unit of time or space
30 6
31 3 x e
Probability function P( x)
32 6 x!
33 6
34 12 Range X = 0, 1, 2, ... where X is the number of events
35 3 in a randomly-chosen unit of time or space
36 6
37 5 Mean
38 4
39 6
40 4 St. Dev.
41 3
42 6
43 6 Skewness 1
44 7
45 3
46 6 Kurtosis 1
47 4 3
48 8
49 5 Comments Always right-skewed, but becomes more
50 3 symmetric for large . Normal approximation
is OK when 10.
Random Number Generation - Uniform Discrete
Comparison of Means
Press F9 to take a new sample of 100.
You can change the 16
510.00 508.12015
parameters! Try it!
Statistic Theory Sample % Diff 84
Mean 500.000 508.120 -1.6 505.00
Parameters St. Dev. 288.386 286.922 0.5 500.000
500.00
Lower limit 1 ? Note Differences of 10% or
more are highlighted.
495.00
Upper limit 999 ? Theory Sample
Histogram of 100 Samples
Random Data
Comparison of Standard Deviations
Item X 25
1 461 20
350.00 288.386
2 44 286.922
15 300.00
3 400 250.00
10 200.00
4 843 150.00
5 311 5 100.00
6 771 50.00
0 0.00
7 271 0 8 6 4 2 0 8 6 4 2 Theory Sample
8 310 1. 0. 0. 0. 0. 0. 9. 9. 9. 9.
10 20 30 40 50 59 69 79 89
9 321
10 122
Objective To illustrate the uniform discrete
distribution. Variates between the limits a and b are
equiprobable. Its mean and standard deviation are m =
(a+b)/2 and s = [(b-a+1)2-1]/12]0.5. Each time you
press F9 you will see 10 random numbers from this
distribution Observe the sample statistics to see if
they resemble the theoretical values for the
distribution.