liveBook · Manning

Probability mass function

As explained in Grokking Statistics

A function that assigns a probability to each possible value of a discrete random variable.

A probability mass function (PMF) assigns a probability to each possible value of a discrete random variable. For a binomial distribution, it answers questions such as: “What is the probability of exactly 7 successes in 10 trials?” section 3.7

A binomial PMF uses three parameters:

Ten trials with 90% success probability

Using scipy.stats.binom.pmf(k=7, n=10, p=.9) gives about 0.057, or 5.7%. To find the probability of 8 or fewer successes, sum the PMF values for k from 0 through 8, giving about 26.4%. section 3.7

import numpy as np

from scipy.stats import binom

n = 10  #1
p = 0.9  #2

k = np.arange(0, n + 1)  #3

y = binom.pmf(k, n, p)  #4

for _k, _y in zip(k, y):  #5
    print(f"The probability of {_k}/{n} successes is {_y:.4f}")  #6

Inspect the PMF for every possible number of successes from 0 through 10. section 3.7

How Grokking Statistics covers it

How deep it goes
Explains parameters, SciPy usage, plotting, and range summation while deliberately avoiding combinations and permutations.
Examples
Demonstrates 10 trials with p=0.9, exactly 7 successes, all outcomes from 0 to 10, and 8-or-fewer cumulative probability.
What it assumes
Assumes only trial count, success count, and success probability, while introducing discrete outcomes through examples.
What you can do after
Apply it via SciPy to calculate and plot exact probabilities for binomial outcomes.
How it connects
Connects probability mass functions with binomial distributions, discrete distributions, simulations, and random variables.

Also explained in

Compare how 3 books explain probability mass function →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Statistics. The section links point to the parts of the book it draws on.