Maximum Likelihood Estimation for a Bernoulli
Distribution
P (Xi = 0) = 1 − p.
P (Xi = 1) = p,
Given observations x1 , x2 , . . . , xN with xi ∈ {0, 1}, we derive the Maximum
Likelihood Estimator (MLE) of p.
Likelihood Function
The probability mass function of a Bernoulli random variable is
P (X = x) = px (1 − p)1−x .
Thus, the likelihood function for the observed data is
L(p) =
N
Y
pxi (1 − p)1−xi .
i=1
This can be rewritten as
L(p) = p
PN
i=1 xi
(1 − p)N −
PN
i=1 xi
.
Log-Likelihood Function
Taking the natural logarithm of the likelihood,
!
!
N
N
X
X
ℓ(p) = log L(p) =
xi log p + N −
xi log(1 − p).
i=1
i=1
Maximization
Differentiating the log-likelihood with respect to p,
PN
PN
N − i=1 xi
dℓ(p)
i=1 xi
=
−
.
dp
p
1−p
Setting the derivative equal to zero,
PN
PN
N − i=1 xi
i=1 xi
=
.
p
1−p
Solving for p,
N
X
xi = pN,
i=1
which gives the Maximum Likelihood Estimator
N
p̂MLE =
1 X
xi .
N i=1
1