# 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:

Here is a screenshot of the model:

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
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "url": "https://modelassist.epixanalytics.com/display/EA/Bayesian+analysis+example%3A+Gender+of+a+random+sample+of+people", "fetch_time": 1702017442000000000, "content_mime_type": "text/html", "warc_filename": "crawl-data/CC-MAIN-2023-50/segments/1700679100724.48/warc/CC-MAIN-20231208045320-20231208075320-00176.warc.gz", "warc_record_offset": 466265224, "warc_record_length": 14520, "token_count": 505, "char_count": 2295, "score": 3.859375, "int_score": 4, "crawl": "CC-MAIN-2023-50", "snapshot_type": "latest", "language": "en", "language_score": 0.9326575994491577, "file_path": "/sailhome/yjruan/project/latent-lm/data/processed/finemath-4plus/finemath-4plus/train-00054-of-00064.parquet"}