Learn practical skills, build real-world projects, and advance your career

A Practical Introduction to Probability

This tutorial is a part of the Zero to Data Analyst Bootcamp by Jovian

alt

Probability is a way of measuring and describing how likely an event is to occur, or how likely it is that a certain condition is true. It's a useful mathematical tool for dealing with uncertainty and randomness. In this tutorial, we'll cover some fundamental concepts, techniques and results in probability and learn how to compute/estimate the probability of an event.

This tutorial covers the following topics:

  • Introduction to randomness and uncertainty
  • Probability of an event given equally like outcomes
  • Estimating probability by conducting experiments
  • Common problems: coin toss, dice roll, playing cards etc.
  • Practical applications of probability
  • Addition rule of probability and mutually exclusive events
  • Probability of complement and sum of probabilities
  • Sequence of independent events and counting combinations
  • Dependent events and the multiplication rule of probability
  • Bayes theorem and posterior probability

How to Run the Code

The best way to learn the material is to execute the code and experiment with it yourself. This tutorial is an executable Jupyter notebook. You can run this tutorial and experiment with the code examples in a couple of ways: using free online resources (recommended) or on your computer.

Option 1: Running using free online resources (1-click, recommended)

The easiest way to start executing the code is to click the Run button at the top of this page and select Run on Binder. You can also select "Run on Colab" or "Run on Kaggle", but you'll need to create an account on Google Colab or Kaggle to use these platforms.

Option 2: Running on your computer locally

To run the code on your computer locally, you'll need to set up Python, download the notebook and install the required libraries. We recommend using the Conda distribution of Python. Click the Run button at the top of this page, select the Run Locally option, and follow the instructions.

Tossing a fair coin

Currency coins are often said to have two sides: a "head" and a "tail".

alt

A fair coin is one that is equally likely to land on either side when tossed or flipped. The side that shows up on top once the coin lands is referred to as the result of a coin toss/flip.

alt

It may be possible to determine the result of a coin toss if we have exact measurements of the physical environment and the forces applied to toss the coin. However, we generally don't have this information at hand and it's very difficult (perhaps even impossible) to perform all these measurements with sufficient accuracy. (image courtesy: Olly, Fotolia)

alt

The assumption of randomness offers a way of working with limited information and uncertainty of outcomes. We say that tossing a coin is an experiment that can lead to one of two results at random. Probability is the measure of how likely each result is.

Here are some examples of randomness and uncertainty:

  • Weather (temperature, rainfall, humidity etc.)
  • Winning a million-dollar lottery
  • The stock price of Apple computers tomorrow
  • Your friend/sibling guessing your email password
  • A political candidate winning an election
  • The GDP of a country twenty years from now

Remember that we consider many of these events random not because they are not deterministic, but because we don't have sufficient information to accurately determine their value.