
5.3 Some Standard Discrete Distributions 141
1)/2 and Var X = (n
2
−1)/12. One of the important uses of discrete uniform
distribution is in nonparametric statistics (p. 482).
Example 5.5. Discrete Uniform: A Basis for Random Sampling. Suppose
that a population is finite and that we need a sample such that every subject
in the population has an equal chance of being selected.
If the population size is N and a sample of size n is needed, then if replace-
ment is allowed (each sampled object is recorded and then returned back to
the population), there would be N
n
possible equally likely samples. If replace-
ment is not allowed or possible (all subjects in the selected sample are to be
different, that is, sampling is without replacement), then there would be
¡
N
n
¢
different equally likely samples (see Sect. 3.5 for a definition of
¡
N
n
¢
).
The theoretical model for random sampling is the discrete uniform distri-
bution. If replacement is allowed, each of
{1,2,.. . , N} has a probability of 1/N
of being selected. In the case of no replacement, possible subsets of n subjects
can be indexed as
{1,2,.. . ,
¡
N
n
¢
}
and each subset has a probability of 1/
¡
N
n
¢
of
being selected.
In MATLAB, random sampling is achieved by the function
randsample. If
the population has n indexed subjects (from 1 to n), the indices in a random
sample of size k are found as
indices=randsample(n,k).
If it is possible to code the entire population as a vector
population, then
taking a sample of size k is done by
y=randsample(population,k).
The default is set to sampling without replacement. For sampling with
replacement, the flag for replacement should be
’true’. If the sampling is done
with replacement, it can be weighted with a nonnegative weight assigned to
each subject in the population:
y=randsample(population,k,true,w). The size
of weight vector
w should be the same as that of population.
For instance,
randsample([’A’ ’C’ ’G’ ’T’],50,true,[1 1.5 1.4 0.9])
%ans = GCCTAGGGCATCCAAGTCGCGGCCGAGAATCAACGTTGCAGTGCTCAAAT
5.3.2 Bernoulli and Binomial Distributions
A simple Bernoulli random variable Y is dichotomous with P(Y = 1) = p and
P(Y = 0) = 1 − p for some 0 ≤ p ≤1 and is denoted as Y ∼ B er(p). It is named
after Jakob Bernoulli (1654–1705) a prominent Swiss mathematician and as-
tronomer (Fig. 5.3a). Suppose that an experiment consists of n independent
trials (Y
1
,... , Y
n
) in which two outcomes are possible (e.g., success or failure),
with
P(success) =P(Y =1) = p for each trial. If X = x is defined as the number
of successes (out of n), then X
=Y
1
+Y
2
+···+Y
n
and there are
¡
n
x
¢
arrangements
of x successes and n
−x failures, each having the same probability p
x
(1−p)
n−x
.
X is a binomial random variable with the PMF