Bechdel: Priors and Posteriors

The Rule

  • More than two women
  • Who talk to eachother
  • About something other than a man

Link to Bechdel Random Sampler

library(tidyverse)

Choosing a prior

Before we start, let’s choose a prior. Base your prior on either:

A. Out of 10 films, how many do you think pass the test?

B. Out of 100 films, how many do you think pass the test?

C. Out of 1000 films, how many do you think pass the test?

Observed data

Update the prior with the data (Posterior parameters)

Plot the prior and posterior distributions

Summarize the posterior mean and credible interval

Combining Prior and Likelihood to get the Posterior

Understanding the Relationship

Binomial Distribution (Likelihood)

The Binomial distribution models the number of successes in a fixed number of trials when each trial has the same probability of success ( ). It is given by:

\[ P(k \mid \theta, n) = \binom{n}{k} \theta^k (1 - \theta)^{n-k} \]

Where:

  • \(k\) = number of successes,
  • \(n\) = total trials,
  • \(\theta\) = unknown probability of success (the parameter we want to estimate).

Beta Distribution (Prior)

The Beta distribution is a flexible probability distribution used to model a probability parameter \(\theta\) on the interval [0,1]. The prior is expressed as:

\[ P(\theta \mid \alpha, \beta) \propto \theta^{\alpha - 1} (1 - \theta)^{\beta - 1} \]

Where:

  • \(\alpha\) and \(\beta\) are shape parameters that determine the prior belief about \(\theta\).
    • \(\alpha\) represents prior “successes” (pseudo-successes).
    • \(\beta\) represents prior “failures” (pseudo-failures).

Why Do Beta and Binomial Work Well Together? (Conjugacy)

In Bayesian inference, if the prior and posterior distributions belong to the same family of distributions, the prior is said to be conjugate to the likelihood.

The Beta distribution is the conjugate prior to the Binomial likelihood because:

\[ \text{Posterior} \propto \text{Likelihood} \times \text{Prior} \]

Substituting the Binomial likelihood and the Beta prior:

\[ P(\theta \mid k, n, \alpha, \beta) \propto \theta^{k + \alpha - 1} (1 - \theta)^{(n - k) + \beta - 1} \]

This results in a Beta posterior distribution with updated parameters:

\[ \theta \mid \text{data} \sim \text{Beta}(\alpha + k, \beta + n - k) \]

Thus, the Beta distribution and Binomial distribution work well together because the posterior remains in the Beta family, making it easy to update beliefs.