Example:
the likelihood of
x
= (0
,
1
,
0
,
1
,
0
,
0
,
1) if
X
∼
Ber
(
p
) is
lik
∝
p
3
(1

p
)
4
.
Example:
the likelihood of a random sample of an
Exp
(
λ
)
L
(
λ
) =
n
Y
i
=1
λe

λx
i
=
λ
n
e

λ
P
n
i
=1
x
i
Often, we take examine the
log likelihood
lnL
(
θ
)
in the above example:
lnL
(
λ
) =
nlogλ

λ
n
X
i
=1
x
i
Or, We can
resample
from this distribution and calculate estimates. Notice that the sampled
values tend to the distributional values.
par(mfrow=c(2,2))
for(n in c(10,100,1000,1000))
{
hist(sample(X,n,replace=TRUE),freq=FALSE,ylim=c(0,.6),main="")
}
Here is a function to calculate the sample mean and variances for many samples.
smeenvar<function(num,ssize,pop){
xbarvec<rep(0,num)
varvec<rep(0,num)
for(i in 1:num){
smple<sample(pop,ssize,replace=TRUE)
xbarvec[i]<mean(smple)
varvec[i]<var(smple)
}
cbind(xbarvec,varvec)
}
3