Kingman's coalescent and Watterson's estimator
Elementary sums
TheoremSum of reciprocals of binomial coefficients \(\binom{k}{2}\)#✓fully proved
∑_{k=2}^n (k.choose 2)⁻¹ = 2 (1 - 1/n) for n ≥ 1 (telescoping 2/(k(k-1))).
theorem sum_inv_choose_two {n : ℕ} (hn : 1 ≤ n) :
∑ k ∈ Icc 2 n, ((k.choose 2 : ℕ) : ℝ)⁻¹ = 2 * (1 - 1 / n)
TheoremWeighted sum of reciprocals of \(\binom{k}{2}\) is twice a harmonic number#✓fully proved
∑_{k=2}^n k (k.choose 2)⁻¹ = 2 H_{n-1}.
The holding-time model
StructureHolding times of Kingman's coalescent#✓fully proved
Kingman's coalescent for a sample of size n, through its holding times: T k is the
time (in units of 2N generations) during which the genealogy has exactly k lineages,
for 2 ≤ k ≤ n. These are independent, and T k is exponential with rate k.choose 2.
The values of T k for k ∉ [2, n] are irrelevant.
structure KingmanTimes (μ : Measure Ω) (n : ℕ) where
/-- `T k` is the holding time while the genealogy has `k` lineages. -/
T : ℕ → Ω → ℝ
/-- `T k` is exponential with rate `k.choose 2`, the number of pairs of lineages. -/
hasLaw : ∀ k ∈ Icc 2 n, HasLaw (T k) (expMeasure (k.choose 2 : ℕ)) μ
/-- The holding times are mutually independent. -/
indep : iIndepFun (fun k : Icc 2 n => T k) μ
T : ℕ → Ω → ℝ
MathlibExt/Biology/PopulationGenetics/Coalescent/Kingman.lean:117
Used by 20
π and S · Pair coalescence time against the total branch length · Tajima's numerator has mean zero · Unbiased estimator of Tajima's variance term · Variance of the number of segregating sites · Tajima's variance identity · Variance of the total branch length · Achaz's estimator is unbiased under Kingman's coalescentDefinitionTime to the most recent common ancestor#✓fully proved
Time to the most recent common ancestor of the sample.
def tmrca : Ω → ℝ := fun ω => ∑ k ∈ Icc 2 n, K.T k ω
Uses 1 · Used by 2
DefinitionTotal branch length of a coalescent genealogy#✓fully proved
Total branch length of the sample genealogy: k branches during T k.
def totalLength : Ω → ℝ := fun ω => ∑ k ∈ Icc 2 n, (k : ℝ) * K.T k ω
Uses 1 · Used by 11
π and S · Pair coalescence time against the total branch length · Tajima's numerator has mean zero · Unbiased estimator of Tajima's variance term · Variance of the number of segregating sites · Tajima's variance identity · Variance of the total branch lengthLemmaPositivity of the number of pairs#✓fully proved
The number of pairs k.choose 2 is positive for k ∈ [2, n].
lemma choose_two_pos {k : ℕ} (hk : k ∈ Icc 2 n) : (0 : ℝ) < ((k.choose 2 : ℕ) : ℝ)
Used by 9
TheoremIntegrability of coalescent holding times#✓fully proved
Each holding time is integrable.
theorem integrable_T {k : ℕ} (hk : k ∈ Icc 2 n) : Integrable (K.T k) μ
Uses 3 · Used by 5
TheoremExpected coalescent holding time#✓fully proved
E[T k] = (k.choose 2)⁻¹.
theorem integral_T {k : ℕ} (hk : k ∈ Icc 2 n) : μ[K.T k] = ((k.choose 2 : ℕ) : ℝ)⁻¹
Uses 3 · Used by 4
TheoremExpected time to the most recent common ancestor#✓fully proved
The expected time to the most recent common ancestor is 2 (1 - 1/n).
theorem integral_tmrca (hn : 1 ≤ n) : μ[K.tmrca] = 2 * (1 - 1 / (n : ℝ))
TheoremIntegrability of the total branch length#✓fully proved
The total branch length is integrable.
theorem integrable_totalLength : Integrable K.totalLength μ
Uses 3 · Used by 1
π and STheoremExpected total branch length of the coalescent#✓fully proved
The expected total branch length is 2 H_{n-1}.
theorem integral_totalLength : μ[K.totalLength] = 2 * (harmonic (n - 1) : ℝ)
TheoremVariance of the time to the most recent common ancestor#✓fully proved
The variance of the time to the most recent common ancestor is
∑_{k=2}^n ((k.choose 2)⁻¹)² (this uses independence).
theorem variance_tmrca :
Var[K.tmrca; μ] = ∑ k ∈ Icc 2 n, (((k.choose 2 : ℕ) : ℝ)⁻¹) ^ 2
Watterson's estimator
TheoremExpected number of segregating sites#✓fully proved
Infinite-sites mutation at rate θ/2 per lineage per unit time: if the number of
segregating sites S is integrable and has conditional mean (θ/2) L given the genealogy
σ-algebra m, then E S = θ H_{n-1}. (Integrability matters: Mathlib's conditional
expectation of a non-integrable function is 0.)
theorem integral_segSites (hm : m ≤ mΩ) [SigmaFinite (μ.trim hm)] (hSi : Integrable S μ)
(hS : μ[S | m] =ᵐ[μ] fun ω => θ / 2 * K.totalLength ω) :
μ[S] = θ * (harmonic (n - 1) : ℝ)
Uses 3 · Used by 2
TheoremIntegrability of Watterson's estimator#✓fully proved
Watterson's estimator S / H_{n-1} is integrable when S is.
theorem integrable_watterson (hSi : Integrable S μ) :
Integrable (fun ω => S ω / (harmonic (n - 1) : ℝ)) μ
TheoremWatterson's estimator is unbiased#✓fully proved
E[S / H_{n-1}] = θ for a sample of size
n ≥ 2.
theorem watterson_unbiased (hm : m ≤ mΩ) [SigmaFinite (μ.trim hm)] (hSi : Integrable S μ)
(hS : μ[S | m] =ᵐ[μ] fun ω => θ / 2 * K.totalLength ω) (hn : 2 ≤ n) :
μ[fun ω => S ω / (harmonic (n - 1) : ℝ)] = θ
Uses 3 · Used by 1
A concrete model
DefinitionCanonical probability space for Kingman holding times#✓fully proved
The canonical probability space for the Kingman holding times of a sample of size n:
the product of the exponential laws Exp (k.choose 2), 2 ≤ k ≤ n.
def piMeasure (n : ℕ) : Measure (Icc 2 n → ℝ) :=
Measure.pi fun k : Icc 2 n => expMeasure ((k : ℕ).choose 2 : ℕ)
Used by 1
DefinitionKingman coalescent from coordinate projections#✓fully proved
The coordinate projections of piMeasure n form a Kingman coalescent; in particular
KingmanTimes is inhabited for every sample size.
MathlibExt.Biology.PopulationGenetics.Coalescent.KingmanTimes.ofPi · 18 lines
def KingmanTimes.ofPi (n : ℕ) : KingmanTimes (piMeasure n) n where
T k ω := if h : k ∈ Icc 2 n then ω ⟨k, h⟩ else 0
hasLaw k hk := by
have hT : (fun ω : Icc 2 n → ℝ => if h : k ∈ Icc 2 n then ω ⟨k, h⟩ else 0)
= fun ω => ω ⟨k, hk⟩ := by
funext ω
simp [hk]
rw [hT]
exact (measurePreserving_eval (fun i : Icc 2 n => expMeasure (((i : ℕ).choose 2 : ℕ) : ℝ))
⟨k, hk⟩).hasLaw
indep := by
have hT : (fun k : Icc 2 n => fun ω : Icc 2 n → ℝ =>
if h : (k : ℕ) ∈ Icc 2 n then ω ⟨k, h⟩ else 0) = fun k ω => id (ω k) := by
funext k ω
simp [k.2]
rw [hT]
exact iIndepFun_pi (μ := fun i : Icc 2 n => expMeasure (((i : ℕ).choose 2 : ℕ) : ℝ))
(fun _ => aemeasurable_id)
structure KingmanTimes (μ : Measure Ω) (n : ℕ) where
/-- `T k` is the holding time while the genealogy has `k` lineages. -/
T : ℕ → Ω → ℝ
/-- `T k` is exponential with rate `k.choose 2`, the number of pairs of lineages. -/
hasLaw : ∀ k ∈ Icc 2 n, HasLaw (T k) (expMeasure (k.choose 2 : ℕ)) μ
/-- The holding times are mutually independent. -/
indep : iIndepFun (fun k : Icc 2 n => T k) μ
MathlibExt/Biology/PopulationGenetics/Coalescent/Kingman.lean:115
def piMeasure (n : ℕ) : Measure (Icc 2 n → ℝ) :=
Measure.pi fun k : Icc 2 n => expMeasure ((k : ℕ).choose 2 : ℕ)
MathlibExt/Biology/PopulationGenetics/Coalescent/Kingman.lean:218
T : ℕ → Ω → ℝ
MathlibExt/Biology/PopulationGenetics/Coalescent/Kingman.lean:117
hasLaw : ∀ k ∈ Icc 2 n, HasLaw (T k) (expMeasure (k.choose 2 : ℕ)) μ
MathlibExt/Biology/PopulationGenetics/Coalescent/Kingman.lean:119
Wright–Fisher → Kingman
DefinitionProbability of no coalescence in one Wright–Fisher generation#✓fully proved
In a Wright–Fisher population of M gene copies, the probability that k lineages,
choosing their parents independently and uniformly, have k distinct parents.
def noCoalProb (M k : ℕ) : ℝ := ∏ i ∈ range k, (1 - (i : ℝ) / M)
Used by 6
TheoremNo-coalescence probability as a falling factorial ratio#✓fully proved
noCoalProb M k is the falling factorial M (M-1) ⋯ (M-k+1) divided by M ^ k.
theorem noCoalProb_eq_descFactorial_div {M : ℕ} (hM : 0 < M) (k : ℕ) :
noCoalProb M k = (M.descFactorial k : ℝ) / (M : ℝ) ^ k
def noCoalProb (M k : ℕ) : ℝ := ∏ i ∈ range k, (1 - (i : ℝ) / M)
MathlibExt/Biology/PopulationGenetics/Coalescent/Kingman.lean:256
Uses 1 · Used by 1
TheoremNo-coalescence probability tends to one#✓fully proved
noCoalProb M k → 1 as M → ∞.
theorem tendsto_noCoalProb_one (k : ℕ) :
Tendsto (fun M : ℕ => noCoalProb M k) atTop (𝓝 1)
def noCoalProb (M k : ℕ) : ℝ := ∏ i ∈ range k, (1 - (i : ℝ) / M)
MathlibExt/Biology/PopulationGenetics/Coalescent/Kingman.lean:256
TheoremKingman's coalescence rate#✓fully proved
For M gene copies (M = 2N), the per-generation
probability that some of k lineages coalesce is (k.choose 2) / M + o(1/M); i.e. in time
units of M generations, coalescences occur at rate k.choose 2.
theorem tendsto_coalescence_rate (k : ℕ) :
Tendsto (fun M : ℕ => (M : ℝ) * (1 - noCoalProb M k)) atTop (𝓝 (k.choose 2 : ℕ))
def noCoalProb (M k : ℕ) : ℝ := ∏ i ∈ range k, (1 - (i : ℝ) / M)
MathlibExt/Biology/PopulationGenetics/Coalescent/Kingman.lean:256
TheoremWright–Fisher coalescence times converge to exponential laws#✓fully proved
After ⌊t M⌋ Wright–Fisher generations (t ≥ 0 coalescent time units), the probability
that k lineages have not coalesced tends to exp (-(k.choose 2) t), the survival function
of the exponential law with rate k.choose 2.
theorem tendsto_noCoalProb_pow_floor (k : ℕ) {t : ℝ} (ht : 0 ≤ t) :
Tendsto (fun M : ℕ => noCoalProb M k ^ ⌊t * M⌋₊) atTop
(𝓝 (Real.exp (-((k.choose 2 : ℕ) : ℝ) * t)))
def noCoalProb (M k : ℕ) : ℝ := ∏ i ∈ range k, (1 - (i : ℝ) / M)
MathlibExt/Biology/PopulationGenetics/Coalescent/Kingman.lean:256
Uses 3 · Used by 1
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.