Abstract
We present an active-learning strategy for undergraduates that applies Bayesian analysis to candy-covered chocolate $\text{m&m's}^\circledR$. The exercise is best suited for small class sizes and tutorial settings, after students have been introduced to the concepts of Bayesian statistics. The exercise takes advantage of the non-uniform distribution of $\text{m&m's}^\circledR$ colours, and the difference in distributions made at two different factories. In this paper, we provide the intended learning outcomes, lesson plan and step-by-step guide for instruction, and open-source teaching materials. We also suggest an extension to the exercise for the graduate-level, which incorporates hierarchical Bayesian analysis.
Introduction
Bayesian statistics can be notoriously abstract for students who are often first trained in frequentist "plug-and-chug" methods. Traditional pedagogical examples—like drawing colored balls from urns or flipping coins—frequently feel dry, repetitive, and disconnected from real-world complexity. This paper introduces a "tasty" active-learning exercise that uses $\text{m&m's}^\circledR$ color distributions to teach Bayesian statistics to undergraduates and graduate students. By treating candy counts as data, students learn to update prior beliefs, calculate posteriors, and perform factory-of-origin inference.
The Active-Learning Framework
The exercise follows a structured workflow designed to demonstrate the core mechanics of Bayesian updating: how prior knowledge and new evidence combine to form a posterior distribution.
- Prior Elicitation: Before seeing any data, students quantify their "gut feeling" about the percentage of blue $\text{m&m's}^\circledR$ in a bag. They translate these beliefs into the hyperparameters ($\alpha, \beta$) of a Beta distribution. This step vividly demonstrates how a strong prior can "resist" small amounts of data, while a weak (flat) prior is easily overwhelmed by new evidence.
- Data Collection: Students open individual bags of $\text{m&m's}^\circledR$ and record the counts of blue vs. non-blue candies. The authors humorously note that students should record their data before eating, as the evidence is literally delicious.
- Likelihood & Posterior Calculation: Using a Binomial likelihood (the standard model for "success/failure" counts), students apply Bayes' Theorem. Because the Beta distribution is the conjugate prior for the Binomial likelihood, the posterior is also a Beta distribution, making the math accessible and analytic.
- Data Pooling: The instructor aggregates the entire class's data to show how the posterior distribution narrows (becomes more certain) as the sample size increases.
Reference Data and Inference
The "surprise twist" of the exercise is that $\text{m&m's}^\circledR$ color proportions aren't universal but depend on the factory of origin. This turns a simple counting exercise into a forensic classification task. Students use their final posterior to guess which factory produced their candy—Hackettstown, NJ (HKP) or Cleveland, TN (CLV)—based on known production targets.
As shown in the figure above, the New Jersey factory targets a simple distribution where Blue and Orange each make up 25% of the total. In contrast, the Tennessee factory uses a more complex distribution where Blue, Orange, and Green are more closely balanced (around 20% each).
Results and Implementation
The exercise has been successfully trialed at multiple levels:
- Undergraduate Trial: A class of approximately 10 students pooled their data (finding ~25% blue) and correctly inferred their bags came from the New Jersey factory. Their posterior mean aligned almost perfectly with the NJ target.
- Graduate Seminar: For more advanced students, the authors extend this to a Hierarchical Bayesian Model using a Multinomial likelihood and Dirichlet priors to model all six colors simultaneously. Using a bulk box from Costco, a graduate group found a lower blue percentage (~21.5%), correctly identifying the Tennessee factory (target: 20.7%).
To support adoption, the authors have released R and Python scripts on GitHub to allow other instructors to implement the plotting and pooling steps instantly in the classroom.
Conclusion and Future Work
The primary limitation of this exercise is its reliance on the Mars Company maintaining consistent production targets. If the company changes its "recipe," the reference distributions would need updating. Future iterations could incorporate the mass of the candies as a continuous variable or use the exercise to introduce computational methods like Markov Chain Monte Carlo (MCMC) sampling and Gibbs sampling in more advanced settings.
Summary updated