The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V20. Probability

Mathlib.Probability.Distributions.Binomial

25 declarations. Mathlib docs · Source

Binomial random variables

This file defines the binomial distribution and binomial random variables, and computes their expectation and variance. For n : ℕ and p : I, the binomial distribution Bin(n, p) is defined as the cardinal of a random subset U of Set.Iic n such that each k ∈ Set.Iic n belongs to U independently with probability p.

Main definition

  • ProbabilityTheory.binomial: Binomial distribution on an arbitrary semiring with parameters n and p.

Implementation notes

We provide the definition binomial with notation Bin(n, P) as the corresponding measure over ℕ. We also introduce a notation Bin(R, n p) for the same measure but over a general AddMonoidWithOne R, that stands for Bin(n, p).map (Nat.cast : ℕ → R). This is in particular useful if one is interested in the binomial distribution as a measure over ℝ or ℤ. Results should be proven for both Bin(n, p) and Bin(R, n, p) when possible, using the first one to prove the second. Note that results concerning Bin(R, n, p) may require [MeasurableSingletonClass R] and/or [CharZero R].

When referring to Bin(n, p) in names, use binomial. When referring to Bin(R, n, p), use map_cast_binomial.

Notation

Bin(n, p) is the binomial distribution with parameters n and p in ℕ. Bin(R, n, p) is the binomial distribution with parameters n and p in R.

Binomial random variables

def ProbabilityTheory.binomial E3 #

ℕ → ↑unitInterval → MeasureTheory.Measure ℕ

The binomial probability distribution with parameter p.

def ProbabilityTheory.«termBin(_,_)» E1 #

Lean.ParserDescr

The binomial probability distribution with parameter p.

def ProbabilityTheory.«termBin(_,_,_)» E1 #

Lean.ParserDescr

The binomial probability distribution with parameter p valued in the semiring R.

theorem ProbabilityTheory.binomial_nat E0 #

∀ {n : ℕ} {p : ↑unitInterval},
  MeasureTheory.Measure.map Nat.cast (ProbabilityTheory.binomial n p) = ProbabilityTheory.binomial n p

theorem ProbabilityTheory.binomial_zero E1 #

∀ {p : ↑unitInterval}, ProbabilityTheory.binomial 0 p = MeasureTheory.Measure.dirac 0

theorem ProbabilityTheory.map_cast_binomial_zero E0 #

∀ {R : Type u_1} [inst : MeasurableSpace R] [inst_1 : AddMonoidWithOne R] {p : ↑unitInterval},
  MeasureTheory.Measure.map Nat.cast (ProbabilityTheory.binomial 0 p) = MeasureTheory.Measure.dirac 0

instance ProbabilityTheory.isProbabilityMeasure_binomial E0 #

∀ {n : ℕ} {p : ↑unitInterval}, MeasureTheory.IsProbabilityMeasure (ProbabilityTheory.binomial n p)

theorem ProbabilityTheory.ae_le_of_hasLaw_binomial E1 #

∀ {Ω : Type u_2} {m : MeasurableSpace Ω} {P : MeasureTheory.Measure Ω} {n : ℕ} {p : ↑unitInterval} {X : Ω → ℕ},
  ProbabilityTheory.HasLaw X (ProbabilityTheory.binomial n p) P → ∀ᵐ (ω : Ω) ∂P, X ω ≤ n

theorem ProbabilityTheory.binomial_real_singleton E1 #

∀ (n k : ℕ) (p : ↑unitInterval), (ProbabilityTheory.binomial n p).real {k} = ↑(n.choose k) * ↑p ^ k * (1 - ↑p) ^ (n - k)

theorem ProbabilityTheory.binomial_singleton E1 #

∀ (n k : ℕ) (p : ↑unitInterval),
  (ProbabilityTheory.binomial n p) {k} = ENNReal.ofReal (↑(n.choose k) * ↑p ^ k * (1 - ↑p) ^ (n - k))

theorem ProbabilityTheory.map_cast_binomial_real_singleton E0 #

∀ {R : Type u_1} [inst : MeasurableSpace R] [inst_1 : AddMonoidWithOne R] [MeasurableSingletonClass R] [CharZero R]
  (n k : ℕ) (p : ↑unitInterval),
  (MeasureTheory.Measure.map Nat.cast (ProbabilityTheory.binomial n p)).real {↑k} =
    ↑(n.choose k) * ↑p ^ k * (1 - ↑p) ^ (n - k)

theorem ProbabilityTheory.binomial_nonneg E0 #

∀ {n : ℕ} {p : ↑unitInterval} {k : ℕ}, 0 ≤ ↑(n.choose k) * ↑p ^ k * (1 - ↑p) ^ (n - k)

theorem ProbabilityTheory.map_cast_binomial_singleton E0 #

∀ {R : Type u_1} [inst : MeasurableSpace R] [inst_1 : AddMonoidWithOne R] [MeasurableSingletonClass R] [CharZero R]
  (n k : ℕ) (p : ↑unitInterval),
  (MeasureTheory.Measure.map Nat.cast (ProbabilityTheory.binomial n p)) {↑k} =
    ENNReal.ofReal (↑(n.choose k) * ↑p ^ k * (1 - ↑p) ^ (n - k))

theorem ProbabilityTheory.binomial_real_zero E0 #

∀ (n : ℕ) (p : ↑unitInterval), (ProbabilityTheory.binomial n p).real {0} = (1 - ↑p) ^ n

theorem ProbabilityTheory.map_cast_binomial_real_zero E0 #

∀ {R : Type u_1} [inst : MeasurableSpace R] [inst_1 : AddMonoidWithOne R] [MeasurableSingletonClass R] [CharZero R]
  (n : ℕ) (p : ↑unitInterval),
  (MeasureTheory.Measure.map Nat.cast (ProbabilityTheory.binomial n p)).real {0} = (1 - ↑p) ^ n

theorem ProbabilityTheory.binomial_real_self E0 #

∀ (n : ℕ) (p : ↑unitInterval), (ProbabilityTheory.binomial n p).real {n} = ↑p ^ n

theorem ProbabilityTheory.map_cast_binomial_real_self E0 #

∀ {R : Type u_1} [inst : MeasurableSpace R] [inst_1 : AddMonoidWithOne R] [MeasurableSingletonClass R] [CharZero R]
  (n : ℕ) (p : ↑unitInterval), (MeasureTheory.Measure.map Nat.cast (ProbabilityTheory.binomial n p)).real {↑n} = ↑p ^ n

theorem ProbabilityTheory.binomial_one_eq_bernoulliMeasure E0 #

∀ (p : ↑unitInterval), ProbabilityTheory.binomial 1 p = ProbabilityTheory.bernoulliMeasure 1 0 p

theorem ProbabilityTheory.binomial_eq_sum_dirac E1 #

∀ (n : ℕ) (p : ↑unitInterval),
  ProbabilityTheory.binomial n p =
    ∑ k ≤ n, ENNReal.ofReal (↑(n.choose k) * ↑p ^ k * (1 - ↑p) ^ (n - k)) • MeasureTheory.Measure.dirac k

theorem ProbabilityTheory.map_cast_binomial_eq_sum_dirac E0 #

∀ {R : Type u_1} [inst : MeasurableSpace R] [inst_1 : AddMonoidWithOne R] [MeasurableSingletonClass R] (n : ℕ)
  (p : ↑unitInterval),
  MeasureTheory.Measure.map Nat.cast (ProbabilityTheory.binomial n p) =
    ∑ k ≤ n, ENNReal.ofReal (↑(n.choose k) * ↑p ^ k * (1 - ↑p) ^ (n - k)) • MeasureTheory.Measure.dirac ↑k

theorem ProbabilityTheory.integrable_map_cast_binomial E1 #

∀ {R : Type u_1} [inst : MeasurableSpace R] [inst_1 : AddMonoidWithOne R] {n : ℕ} {p : ↑unitInterval} {E : Type u_3}
  [inst_2 : NormedAddCommGroup E] [MeasurableSingletonClass R] (f : R → E),
  MeasureTheory.Integrable f (MeasureTheory.Measure.map Nat.cast (ProbabilityTheory.binomial n p))

theorem ProbabilityTheory.integrable_binomial E1 #

∀ {n : ℕ} {p : ↑unitInterval} {E : Type u_3} [inst : NormedAddCommGroup E] (f : ℕ → E),
  MeasureTheory.Integrable f (ProbabilityTheory.binomial n p)

theorem ProbabilityTheory.integral_binomial E1 #

∀ {n : ℕ} {p : ↑unitInterval} {E : Type u_3} [inst : NormedAddCommGroup E] [inst_1 : NormedSpace ℝ E] [CompleteSpace E]
  (f : ℕ → E),
  ∫ (x : ℕ), f x ∂ProbabilityTheory.binomial n p = ∑ k ≤ n, (↑(n.choose k) * ↑p ^ k * (1 - ↑p) ^ (n - k)) • f k

theorem ProbabilityTheory.integral_map_cast_binomial E1 #

∀ {R : Type u_1} [inst : MeasurableSpace R] [inst_1 : AddMonoidWithOne R] {n : ℕ} {p : ↑unitInterval} {E : Type u_3}
  [inst_2 : NormedAddCommGroup E] [inst_3 : NormedSpace ℝ E] [CompleteSpace E] [MeasurableSingletonClass R] (f : R → E),
  ∫ (x : R), f x ∂MeasureTheory.Measure.map Nat.cast (ProbabilityTheory.binomial n p) =
    ∑ k ≤ n, (↑(n.choose k) * ↑p ^ k * (1 - ↑p) ^ (n - k)) • f ↑k

theorem ProbabilityTheory.integral_of_hasLaw_binomial E1 #

∀ {Ω : Type u_2} {m : MeasurableSpace Ω} {P : MeasureTheory.Measure Ω} {n : ℕ} {p : ↑unitInterval} {X : Ω → ℝ},
  ProbabilityTheory.HasLaw X (MeasureTheory.Measure.map Nat.cast (ProbabilityTheory.binomial n p)) P →
    ∫ (x : Ω), X x ∂P = ↑p * ↑n

Expectation of a binomial random variable.

The expectation of a binomial random variable with parameters n and p is pn.