Homepage > MCMC

## Bernoulli Trials

Consider independent Bernoulli trials with success probability . Having observed the data , we wish to estimate the parameter . In maximum likelihood methed we construct the likelihood function

where . And we obtain the MLE

Beta distribution. The pdf

is known as the beta distribution with parameters and . The mean and the variance are and , respectively. And the mode (at which the density is maximized) is given by if and . The function
> rbeta(n,alpha,beta)

generates independent random sample from the beta distribution.

Bayes estimate. When the uninformative prior , the posterior density is give by , and the expected value of is calculated as

Explore it. Download bernoulli.r. The function bernoulli() generates data, and compares the estimates of two distinct methods. See how they differ in a particular outcome, and repeat the experiment with the same size. Increase the size, and observe the similarity of the two estimate.

> source("bernoulli.r")
> bernoulli()
> bernoulli(size=20)