Explore our extensive collection of courses designed to help you master various subjects and skills. Whether you're a beginner or an advanced learner, there's something here for everyone.
Join us for our free workshops, webinars, and other events to learn more about our programs and get started on your journey to becoming a developer.
For all the self-taught geeks out there, here is our content library with most of the learning materials we have produced throughout the years.
It makes sense to start learning by reading and watching videos about fundamentals and how things work.
Data Science and Machine Learning - 16 wks
Full-Stack Software Developer - 16w
Search from all Lessons
Curated list of small interactive and incremental exercises you can take to get better at any coding skill.
Curated section of projects to build while learning with simple instructions, videos, solutions, and more.
Guides on different topics related to the technologies that we teach in our courses
The probability of an event is a number between 0 and 1, where, roughly speaking, 0 indicates impossibility of the event and 1 indicates certainty. The higher the probability of an event, the more likely it is that the event will occur. A simple example is the tossing of a fair (unbiased) coin. Since the coin is fair, the two outcomes ("heads" and "tails") are both equally probable; the probability of "heads" equals the probability of "tails"; and since no other outcomes are possible, the probability of either "heads" or "tails" is 1/2 (which could also be written as 0.5 or 50%). --- Source
import matplotlib.pyplot as plt import numpy as np import pandas as pd
Consider the example of tossing a fair coin to root our vocabulary and symbols. We will say the probability of getting a head is the total ways for this event to happen divided by the number of all possible outcomes.
EXAMPLE I: A Fair Coin
With one fair coin, we have outcomes either heads or tails. The outcome of interest is either a heads or tails. We would say the probability of each is :
Note that these probabilities sum to 1.
EXAMPLE II: An Unfair Coin
An example of an unfair coin would be anything that does not have equal probability. For example:
import scipy.stats as stats fig, ax = plt.subplots(1, 2, figsize = (20, 5)) fair_coin = stats.bernoulli(.5).pmf([0, 1]) ax.bar(['heads', 'tails'], fair_coin, color=['gray', 'white'], edgecolor = 'black') ax.set_title('Probabilities for a Fair Coin'); unfair_coin = stats.bernoulli(.4).pmf([0, 1]) ax.bar(['heads', 'tails'], unfair_coin, color = ['gray', 'white'], edgecolor = 'black') ax.set_title('Probabilities for an Unfair Coin');
We can describe this kind of event as a function. Specifically, a situation in which there are two possible outcomes with a probability attached to each. This is called a bernoulli distribution, and the functional form is:
In our example of an unfair coin, if we consider heads as 0 and tails as 1 (), we would have:
which equals 0.6. Similarly, the probability of a tails ():
which equals 0.4.
def bernoulli(k, p): return p*k + (1-p)*(1 - k)