~/ learn/ afm-113/ cards/ The binomial distribution
1 of 7

Compute P(X = 2) for X ~ Bin(12, 0.15) with math.comb, and the mean, variance and SD from np and np(1 − p).

Compute P(X = 2) for X ~ Bin(12, 0.15) with math.comb, and the mean, variance and SD from np and np(1 − p).

Answer

import math n, p = 12, 0.15 x = 2 prob = math.comb(n, x) * p ** x * (1 - p) ** (n - x) mean = n * p var = n * p * (1 - p) print(f"P(X=2)={prob:.4f} mean={mean:.2f} var={var:.4f} sd={math.sqrt(var):.4f}")

IBS1 §4.2 (binomial), IS1 §4.3 (tilde notation, non-binomial counter-example), CC BY 4.0 — shape only; original dataset

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/4dd32182-8a9d-49d3-b78a-46f2a3dde0a8/flashcard utf-8 LF