A courseware module that covers fundamental concepts including the basics of probability, random variables, and Bayes' Theorem.


Updated 27 Jan 2023

From GitHub

View License on GitHub

Fundamentals of Probability Theory

View Fundamentals of Probability Theory on File Exchange or Open in MATLAB Online

Curriculum Module
Created with R2021a. Compatible with R2021a and later releases.


This package contains live scripts and supporting files to teach the fundamental concepts in probability theory and statistical inference. These materials are designed to be flexible and can be easily modified to accommodate a variety of teaching and learning methods. Used in a sequence, the live scripts progressively add depth to the topic. However, each script or section can be easily adapted for standalone use. The live scripts include a brief background, interactive illustrations, tasks, reflection questions, and application examples.

This module can be used as part of a lecture, as activities in an instructional setting, or as interactive assignments to be completed outside of class. The live script sections contains direct instructions or tasks to illustrate the basics and additional reflection questions that are more open-ended.

Get started with each live script by running it one section at a time. To stop running the script or a section midway (for example, when an animation is in progress), use the Stop button in the Run section of the Live Editor tab in the MATLAB toolstrip.

Prerequisite Domain Knowledge

This module assumes a knowledge of basic concepts in set theory, such as ⋃ (union) and ⋂ (intersection). It also assumes basic fluency in mathematical notation for Σ (summation) and Π (product). Other notation relevant to probability theory is introduced within the module as needed.

Suggested Prework

MATLAB Onramp – a free two-hour introductory tutorial to learn the essentials of MATLAB®.


probabilityIntro.mlx Open in MATLAB Online Learning Goals

  • Explain the commonly used terms in probability such as random experiment, random process, trial, event, outcome, countable, equally likely, sample space, mutual independence.
  • Define and compute classical probability of events.
    classical probability
  • Define and compute empirical probability of events.
    empirical probability
  • Explain the limitations and strengths of the subjective, classical, and empirical perspectives of probability.
  • State and apply Kolmogorov's axioms of probability.

randomVariables.mlx, randomVariableApp.mlapp Open in MATLAB Online
Learning Goals

  • Define and create random variables to describe random processes.
  • Generate an empirical distribution of random variables through random sampling.
  • Explain the meaning of expectation and variance for random variables.
  • Explain the difference between continuous and discrete random variables.
  • Identify and use the discrete uniform and continuous normal probability distributions.
  • Define and apply the probability density function and cumulative density function to find the probability of a random variable's value falling within a given interval.
  • State the Central Limit Theorem and explain its implications for statistical inference.

central limit theorem

inferenceBayes.mlx Open in MATLAB Online
Learning Goals

  • Define conditional probability, and explain how it affects the sample space.
    conditional probability
  • State Bayes' theorem mathematically, and explain its implications for statistical inference.
    conditional probability
  • Apply Bayes' theorem to practical real-world problems.

Data files: people.png(optional)


MATLAB®, Statistics and Machine Learning Toolbox™, Image Processing Toolbox™


The license for this module is available in the LICENSE.TXT file in this GitHub repository.

Educator Resources

Have any questions or feedback? Contact the MathWorks online teaching team.

Authored by: Pooja Lalan
Maintained by: Emma Smith Zbarsky

Copyright 2021 The MathWorks, Inc.

Cite As

Emma Smith Zbarsky (2023). Probability-Theory (, GitHub. Retrieved .

MATLAB Release Compatibility
Created with R2021a
Compatible with any release
Platform Compatibility
Windows macOS Linux
More Files in the  Distance Learning Community

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes

See release notes for this release on GitHub:


See release notes for this release on GitHub:


See release notes for this release on GitHub:


See release notes for this release on GitHub:


See release notes for this release on GitHub:


To view or report issues in this GitHub add-on, visit the GitHub Repository.
To view or report issues in this GitHub add-on, visit the GitHub Repository.