2025-10-20

Slide 1: What is Bayesian Inference?

  • A powerful statistical method based on Bayes’ Theorem.
  • It’s a framework for updating our beliefs about parameters in light of new evidence (data).
  • This approach is heavily used in fields like Computer Science (e.g., spam filters, AI) and traditional sciences.
  • Core Idea: Start with a “prior” belief, collect data, and update to a “posterior” belief.

Slide 2: The Model (LaTeX)

Bayesian Theorem

The foundation of Bayesian inference is Bayes’ Theorem:

\[ P(\theta | D) = \frac{P(D | \theta) \cdot P(\theta)}{P(D)} \]

  • \(P(\theta | D)\) is the Posterior (our updated belief)
  • \(P(D | \theta)\) is the Likelihood (from data)
  • \(P(\theta)\) is the Prior (our initial belief)

Slide 3: The “Update” Process (LaTeX)

In practice, we use a simpler form:

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

This means our new belief Posterior is a blend of what the data tells us Likelihood and what we originally thought Prior.

Slide 4: Example: The “Prior” Belief

Let’s estimate a coin’s fairness (\(\theta\)). Before flipping, we assume all probabilities (0 to 1) are equally likely. This is a Beta(1, 1) distribution.

Slide 5: The “Posterior” Belief

We flip the coin 10 times and get 7 Heads. We update our belief.

Our new belief is a Beta(1+7, 1+3) = Beta(8, 4) distribution.

Slide 6: R Code for the Posterior Plot

This is the R code used to generate the plot on the previous slide. We use echo = TRUE to display the code.

# We use dbeta() to calculate the density
posterior_data <- data.frame(theta = seq(0, 1, by = 0.01)) %>%
  mutate(density = dbeta(theta, 8, 4))

# We use ggplot() to plot it
ggplot(posterior_data, aes(x = theta, y = density)) +
  geom_line(color = "#8C1D40", size = 1.5) +
  geom_area(fill = "#8C1D40", alpha = 0.3) +
  labs(title = "Posterior Belief: Beta(8, 4)")

Slide 7: Interactive 3D Plot (Plotly)

In complex models, we visualize 3D posterior densities. This is an interactive 3D surface plot using R’s built-in volcano dataset.

Slide 8: Conclusion

  • We used R Markdown to create this presentation.
  • Bayesian inference updates beliefs using data.
  • We moved from a Beta(1, 1) Prior to a Beta(8, 4) Posterior.
  • Tools like ggplot2 and plotly help visualize these statistical concepts.