# Bayesian analysis example: Gender of a random sample of people

20 people are randomly picked off a city street in France. Whether they are male or female is noted on 20 identical pieces of paper, put into a hat and the hat is brought to me. I have not seen these 20 people. I take out five pieces of paper from the hat and read them - three are female. I am then asked to estimate the number of females in the original group of twenty.

I can express my estimate as a confidence distribution of the possible values. I could argue that prior to reading the five names I had no knowledge of the number of people who would be female. Actually, roughly 50% of people are female and so I do have quite a specific prior: = Binomial(50%,20). Excel has a function that automatically calculates the Binomial probability mass function:

π(θ) =BINOMDIST(θ,20,0.5,0)

The likelihood function relating to sampling five people from the population is hypergeometric, where we know the total population (i.e. M = 20), we know the sample size (n = 5), we know the number observed in the sample with the required property (x = 3) but don't know the number of females D, which we denote θ as it is the parameter to be estimated. Thus, we can use the Excel Hypergeometric function to calculate the likelihood function:

l(X|θ) =HYPGEOMDIST(3,5,θ,20)

The model could be reached here: Gender

The links to the Gender software specific models are provided here: Gender

Here is a screenshot of the model:  Gender

Here is a screenshot of the model: Figure 1 below shows the resultant posterior distribution, together with the likelihood function and the prior. Here we can see that the prior is very strong and the amount of information embedded in the likelihood function is small, so the posterior distribution is quite close to the prior. The posterior distribution is a balance between the prior and likelihood function. Hence, the peak of the posterior distribution now lies somewhere between the peaks of the prior and likelihood function. The effect of the likelihood function is small because the sample is small (a sample of five) and because it is in reasonable agreement with the prior (the prior has a maximum at θ = 10, and this value of θ also produces one of the highest likelihood function values).

• No labels