Stat.OrderStatistic.WeightedConcomitant
Finite-sample theory of the statistic ∑ⱼ aⱼ Y₍ⱼ₎, where the marks Y are sorted by a continuously distributed coordinate and aⱼ are fixed cell weights.
BernsteinKernel 2 core · 3 supporting The density kernel associated with arbitrary nonnegative cell masses, and its normalization by the beta integral. ★ integral_bernsteinCell
Finite Bernstein cell kernels
The density kernel associated with arbitrary nonnegative cell masses, and its normalization by the beta integral.
Proof route: use the integer-parameter beta integral to normalize each basis term. Exchange the finite sum and integral to normalize the mixture.
For a sample size, cell masses, and evaluation point, the Bernstein cell-average kernel is the degree N-1 Bernstein mixture multiplied by N.
For a positive sample size, cell masses with unit sum, the Bernstein kernel integrates to one on the unit interval.
Formal statement
Proof (Lean source)
3 supporting declarations (lemmas, instances)
-
measurable_bernsteinCelltheorem — For any finite cell masses, the Bernstein kernel is measurable.Proof (Lean source)
theorem measurable_bernsteinCell {N : ℕ} (a : Fin N → ℝ) : Measurable (bernsteinCell N a) := by unfold bernsteinCell fun_prop -
bernsteinCell_nonnegtheorem — For nonnegative cell masses and a point in the unit interval, the Bernstein kernel is nonnegative.hypothesesconclusion0 ≤ bernsteinCell N a uProof (Lean source)
theorem bernsteinCell_nonneg {N : ℕ} {a : Fin N → ℝ} (ha : ∀ j, 0 ≤ a j) {u : ℝ} (hu : u ∈ Icc (0 : ℝ) 1) : 0 ≤ bernsteinCell N a u := by unfold bernsteinCell apply mul_nonneg (by positivity) apply Finset.sum_nonneg intro j hj exact mul_nonneg (mul_nonneg (mul_nonneg (ha j) (by positivity)) (pow_nonneg hu.1 _)) (pow_nonneg (sub_nonneg.mpr hu.2) _) -
integral_bernstein_basistheorem — For a positive sample size and cell index, the Bernstein basis density associated with that cell integrates to one.hypothesesProof (Lean source)
theorem integral_bernstein_basis {N : ℕ} (hN : 0 < N) (j : Fin N) : (∫ u in Icc (0 : ℝ) 1, (N : ℝ) * (choose (N - 1) (j : ℕ) : ℝ) * u ^ (j : ℕ) * (1 - u) ^ (N - 1 - (j : ℕ)) ∂volume) = 1 := by let k := N - 1 - (j : ℕ) have hj : (j : ℕ) ≤ N - 1 := by omega have hsum : (j : ℕ) + k + 1 = N := by dsimp [k]; omega have hbeta : (∫ u in (0 : ℝ)..1, ((u ^ (j : ℕ) * (1 - u) ^ k : ℝ) : ℂ)) = Complex.betaIntegral ((j : ℕ) + 1) (k + 1) := by rw [Complex.betaIntegral] apply intervalIntegral.integral_congr intro u hu have hu0 : 0 ≤ u := by simpa using hu.1 have hu1 : u ≤ 1 := by simpa using hu.2 dsimp simp only [Complex.ofReal_mul, Complex.ofReal_pow, Complex.ofReal_sub, Complex.ofReal_one] simp [Complex.cpow_natCast] have heval := Complex.betaIntegral_eq_Gamma_mul_div ((j : ℕ) + 1) (k + 1) (by simp only [Complex.add_re, Complex.natCast_re, Complex.one_re]; positivity) (by simp only [Complex.add_re, Complex.natCast_re, Complex.one_re]; positivity) rw [← hbeta] at heval have hg1 : Complex.Gamma ((j : ℕ) + 1) = ((j : ℕ).factorial : ℂ) := by simpa using Complex.Gamma_nat_eq_factorial (j : ℕ) have hg2 : Complex.Gamma (k + 1) = (k.factorial : ℂ) := by simpa using Complex.Gamma_nat_eq_factorial k have hg3 : Complex.Gamma (((j : ℕ) + 1) + (k + 1)) = (N.factorial : ℂ) := by have harg : ((j : ℕ) : ℂ) + 1 + ((k : ℕ) : ℂ) + 1 = (N : ℂ) + 1 := by exact_mod_cast (show (j : ℕ) + 1 + k + 1 = N + 1 by omega) rw [← add_assoc, harg] exact Complex.Gamma_nat_eq_factorial N rw [hg1, hg2, hg3, intervalIntegral.integral_ofReal] at heval have hreal : (∫ u in (0 : ℝ)..1, u ^ (j : ℕ) * (1 - u) ^ k) = (j : ℕ).factorial * k.factorial / N.factorial := by exact Complex.ofReal_inj.mp (by simpa using heval) rw [intervalIntegral.integral_of_le (by norm_num : (0 : ℝ) ≤ 1), ← integral_Icc_eq_integral_Ioc] at hreal rw [show N - 1 - (j : ℕ) = k from rfl] simp_rw [mul_assoc] rw [integral_const_mul, integral_const_mul, hreal] have hchoose : (choose (N - 1) (j : ℕ) : ℝ) * (j : ℕ).factorial * k.factorial = (N - 1).factorial := by exact_mod_cast Nat.choose_mul_factorial_mul_factorial hj have hfac : (N.factorial : ℝ) = N * (N - 1).factorial := by have : N - 1 + 1 = N := by omega rw [← this, Nat.factorial_succ] push_cast congr 1 rw [hfac] field_simp nlinarith [hchoose]
ConcomitantCore 2 core · 7 supporting Continuous CDF transport of iid sorting coordinates, almost-sure rank equivalence, and the conditional-mean and tagged-rank ingredients of the Bernstein-kernel expectation of bounded marks; the expectation formula itself ★ uniform_tagged_rank_cell_integral
Rank-weighted concomitant expectation
Continuous CDF transport of iid sorting coordinates, almost-sure rank
equivalence, and the conditional-mean and tagged-rank ingredients of the
Bernstein-kernel expectation of bounded marks; the expectation formula itself
is proved in ConcomitantExpectation.
Proof route: apply Measure.pi_map_pi to the one-coordinate CDF transport.
Uniform coordinates have no ties; strict ordering is therefore preserved by
the monotone CDF almost surely. Conditional expectation against the CDF's
comap sigma algebra replaces each mark by m(U). The rank of one tagged
uniform observation has the binomial cell kernel. Pull almost-everywhere
measurability and bounds of m back along the measure-preserving CDF map.
For cell weights and a sample of sorting coordinates with marks, the rank-weighted concomitant statistic sums each sorted mark against its cell weight.
For a positive sample size, a tagged coordinate, a rank, and an almost-everywhere measurable bounded test function, the iid unit-uniform expectation of the test function at the tagged coordinate, on the event that this coordinate has that (zero-based) rank j in the sample, equals the integral over the unit interval of the test function against the binomial weight C(N−1, j) v^j (1−v)^(N−1−j).
Formal statement
Proof (Lean source)
7 supporting declarations (lemmas, instances)
-
cdf_transport_iidtheorem — For a probability law of marked observations whose sorting-coordinate CDF is continuous, the coordinatewise CDF pushforward of the iid sample is iid unit-uniform.hypothesesProof (Lean source)
theorem cdf_transport_iid {N : ℕ} (μ : Measure (ℝ × ℝ)) [IsProbabilityMeasure μ] (hcont : Continuous (fun t => cdf (μ.map Prod.fst) t)) : (Measure.pi (fun _ : Fin N => μ)).map (fun x i => cdf (μ.map Prod.fst) (x i).1) = iidSample uniform01 N := by have hfst : Measurable (Prod.fst : ℝ × ℝ → ℝ) := measurable_fst have : IsProbabilityMeasure (μ.map Prod.fst) := Measure.isProbabilityMeasure_map hfst.aemeasurable have hmap : μ.map (fun p : ℝ × ℝ => cdf (μ.map Prod.fst) p.1) = uniform01 := by simpa only [Function.comp_def] using (Measure.map_map hcont.measurable hfst).symm.trans (cdf_pushforward_of_continuous (μ.map Prod.fst) hcont) change (Measure.pi (fun _ : Fin N => μ)).map (fun x i => cdf (μ.map Prod.fst) (x i).1) = Measure.pi (fun _ : Fin N => uniform01) haveI : IsProbabilityMeasure (μ.map (fun p : ℝ × ℝ => cdf (μ.map Prod.fst) p.1)) := Measure.isProbabilityMeasure_map (hcont.measurable.comp hfst).aemeasurable haveI : ∀ _ : Fin N, SigmaFinite (μ.map (fun p : ℝ × ℝ => cdf (μ.map Prod.fst) p.1)) := fun _ => inferInstance simpa only [Function.comp_def, hmap] using (Measure.pi_map_pi (μ := fun _ : Fin N => μ) (f := fun _ p => cdf (μ.map Prod.fst) p.1) (fun _ : Fin N => (hcont.measurable.comp hfst).aemeasurable)) -
sort_cdf_eq_aetheorem — For a marked observation law with continuous sorting-coordinate CDF, original and CDF coordinates sort in the same order almost surely.hypothesesProof (Lean source)
theorem sort_cdf_eq_ae {N : ℕ} (μ : Measure (ℝ × ℝ)) [IsProbabilityMeasure μ] (hcont : Continuous (fun t => cdf (μ.map fst) t)) : ∀ᵐ x ∂Measure.pi (fun _ : Fin N => μ), sort (fun i => (x i).1) = sort (fun i => cdf (μ.map fst) (x i).1) := by classical have hface (i j : Fin N) (hij : i ≠ j) : volume {u : Fin N → ℝ | u i = u j} = 0 := by let L : (Fin N → ℝ) →ₗ[ℝ] ℝ := (LinearMap.proj i : (Fin N → ℝ) →ₗ[ℝ] ℝ) - LinearMap.proj j have hL : L ≠ 0 := by intro h have h' := LinearMap.congr_fun h (fun k => if k = i then 1 else 0) simp [L, hij.symm] at h' have hker : LinearMap.ker L ≠ ⊤ := by intro h exact hL (LinearMap.ker_eq_top.mp h) have hs : {u : Fin N → ℝ | u i = u j} = (LinearMap.ker L : Set (Fin N → ℝ)) := by ext u simp [L, LinearMap.mem_ker, sub_eq_zero] rw [hs] exact Measure.addHaar_submodule volume (LinearMap.ker L) hker have huniform : ∀ᵐ u ∂iidSample uniform01 N, ∀ i j : Fin N, i ≠ j → u i ≠ u j := by apply Filter.eventually_all.mpr intro i apply Filter.eventually_all.mpr intro j by_cases hij : i = j · exact Filter.Eventually.of_forall (fun _ h => (h hij).elim) · have hne : ∀ᵐ u ∂(volume : Measure (Fin N → ℝ)), u i ≠ u j := by exact ae_iff.mpr (by simpa only [not_not] using hface i j hij) rw [iid_uniform_cube_law] exact (ae_restrict_of_ae hne).mono (fun u hu _ => hu) have htransport := cdf_transport_iid (N := N) μ hcont have hcoord : ∀ᵐ x ∂Measure.pi (fun _ : Fin N => μ), ∀ i j : Fin N, i ≠ j → cdf (μ.map fst) (x i).1 ≠ cdf (μ.map fst) (x j).1 := by rw [← htransport] at huniform exact ae_of_ae_map (by apply aemeasurable apply measurable_pi_iff.mpr intro i exact hcont.measurable.comp (measurable_fst.comp (measurable_pi_apply i)) : AEMeasurable (fun x : Fin N → ℝ × ℝ => fun i => cdf (μ.map fst) (x i).1) (Measure.pi (fun _ : Fin N => μ))) huniform filter_upwards [hcoord] with x hx let f : Fin N → ℝ := fun i => (x i).1 let g : Fin N → ℝ := fun i => cdf (μ.map fst) (x i).1 have hg : Injective g := by intro i j h by_contra hij exact hx i j hij h have hmono : Monotone (g ∘ sort f) := (ProbabilityTheory.monotone_cdf (μ.map fst)).comp (Tuple.monotone_sort f) change sort f = sort g apply (Tuple.eq_sort_iff).2 constructor · exact hmono · intro i j hij heq exact (hij.ne ((sort f).injective (hg heq))).elim -
conditionalMean_exists_measurable_versiontheorem — For a marked observation law and an almost-everywhere conditional mean version, that version has a measurable representative on the CDF coordinate.Proof (Lean source)
theorem conditionalMean_exists_measurable_version (μ : Measure (ℝ × ℝ)) [IsProbabilityMeasure μ] (m : ℝ → ℝ) (hm : (fun p : ℝ × ℝ => m (cdf (μ.map fst) p.1)) =ᵐ[μ] μ[(fun p : ℝ × ℝ => p.2) | comap (fun p : ℝ × ℝ => cdf (μ.map fst) p.1) inferInstance]) : ∃ g : ℝ → ℝ, Measurable g ∧ (fun p : ℝ × ℝ => m (cdf (μ.map fst) p.1)) =ᵐ[μ] (fun p => g (cdf (μ.map fst) p.1)) := by let F : ℝ × ℝ → ℝ := fun p => cdf (μ.map fst) p.1 let c : ℝ × ℝ → ℝ := μ[(fun p : ℝ × ℝ => p.2) | comap F inferInstance] have hc : @StronglyMeasurable (ℝ × ℝ) ℝ _ (comap F inferInstance) c := stronglyMeasurable_condExp obtain ⟨g, hg, hgc⟩ := hc.exists_eq_measurable_comp refine ⟨g, hg.measurable, ?_⟩ exact hm.trans (Filter.Eventually.of_forall fun p => by simpa only [Function.comp_apply] using congrFun hgc p) -
conditionalMean_ae_eq_uniform_versiontheorem — A conditional-mean version that factors measurably through a continuous CDF equals that measurable factor almost everywhere under the uniform law.hypothesesProof (Lean source)
theorem conditionalMean_ae_eq_uniform_version (μ : Measure (ℝ × ℝ)) [IsProbabilityMeasure μ] (hcont : Continuous (fun t => cdf (μ.map Prod.fst) t)) (m : ℝ → ℝ) (hm : (fun p : ℝ × ℝ => m (cdf (μ.map Prod.fst) p.1)) =ᵐ[μ] μ[(fun p : ℝ × ℝ => p.2) | comap (fun p : ℝ × ℝ => cdf (μ.map Prod.fst) p.1) inferInstance]) : ∃ g : ℝ → ℝ, Measurable g ∧ m =ᵐ[uniform01] g := by obtain ⟨g, hg, hcomp⟩ := conditionalMean_exists_measurable_version μ m hm refine ⟨g, hg, ?_⟩ let ν : Measure ℝ := μ.map Prod.fst haveI : IsProbabilityMeasure ν := Measure.isProbabilityMeasure_map measurable_fst.aemeasurable have hfst : (fun t => m (cdf ν t)) =ᵐ[ν] (fun t => g (cdf ν t)) := by exact ae_eq_of_comp_fst μ (fun t => m (cdf ν t)) (fun t => g (cdf ν t)) hcomp exact ae_eq_of_comp_continuous_cdf ν hcont m g hfst -
conditionalMean_comp_mem_Icc_aetheorem — A conditional mean of a mark in [0,1] stays in [0,1] almost surely under the original marked observation law.Proof (Lean source)
theorem conditionalMean_comp_mem_Icc_ae (μ : Measure (ℝ × ℝ)) [IsProbabilityMeasure μ] (hmark : ∀ᵐ p ∂μ, p.2 ∈ Icc (0 : ℝ) 1) (m : ℝ → ℝ) (hm : (fun p : ℝ × ℝ => m (cdf (μ.map fst) p.1)) =ᵐ[μ] μ[(fun p : ℝ × ℝ => p.2) | comap (fun p : ℝ × ℝ => cdf (μ.map fst) p.1) inferInstance]) : ∀ᵐ p ∂μ, m (cdf (μ.map fst) p.1) ∈ Icc (0 : ℝ) 1 := by have hlo : ∀ᵐ p ∂μ, (0 : ℝ) ≤ p.2 := hmark.mono fun _ hp => hp.1 have hhi : ∀ᵐ p ∂μ, p.2 ≤ (1 : ℝ) := hmark.mono fun _ hp => hp.2 have hcondlo : ∀ᵐ p ∂μ, (0 : ℝ) ≤ μ[(fun p : ℝ × ℝ => p.2) | comap (fun p : ℝ × ℝ => cdf (μ.map fst) p.1) inferInstance] p := condExp_nonneg hlo have hcondhi : ∀ᵐ p ∂μ, μ[(fun p : ℝ × ℝ => p.2) | comap (fun p : ℝ × ℝ => cdf (μ.map fst) p.1) inferInstance] p ≤ (1 : ℝ) := condExp_le_nonneg_const (by norm_num) hhi filter_upwards [hm, hcondlo, hcondhi] with p hp hp0 hp1 constructor · simpa only [hp] using hp0 · simpa only [hp] using hp1 -
aemeasurable_conditionalMean_uniformtheorem — For a marked observation law, continuous sorting-coordinate CDF, and conditional mean version, the version is almost-everywhere measurable under the unit-uniform law.Proof (Lean source)
theorem aemeasurable_conditionalMean_uniform (μ : Measure (ℝ × ℝ)) [IsProbabilityMeasure μ] (hcont : Continuous (fun t => cdf (μ.map fst) t)) (m : ℝ → ℝ) (hm : (fun p : ℝ × ℝ => m (cdf (μ.map fst) p.1)) =ᵐ[μ] μ[(fun p : ℝ × ℝ => p.2) | comap (fun p : ℝ × ℝ => cdf (μ.map fst) p.1) inferInstance]) : AEMeasurable m uniform01 := by obtain ⟨g, hg, hmg⟩ := conditionalMean_ae_eq_uniform_version μ hcont m hm exact hg.aemeasurable.congr hmg.symm -
conditionalMean_mem_Icc_aetheorem — For a marked observation law, continuous sorting-coordinate CDF, marks in the unit interval almost surely, and a conditional mean version, that version lies in the unit interval almost everywhere under the uniform law.hypothesesconclusion∀ᵐ u ∂uniform01, m u ∈ Icc (0 : ℝ) 1Proof (Lean source)
theorem conditionalMean_mem_Icc_ae (μ : Measure (ℝ × ℝ)) [IsProbabilityMeasure μ] (hcont : Continuous (fun t => cdf (μ.map Prod.fst) t)) (hmark : ∀ᵐ p ∂μ, p.2 ∈ Icc (0 : ℝ) 1) (m : ℝ → ℝ) (hm : (fun p : ℝ × ℝ => m (cdf (μ.map Prod.fst) p.1)) =ᵐ[μ] μ[(fun p : ℝ × ℝ => p.2) | comap (fun p : ℝ × ℝ => cdf (μ.map Prod.fst) p.1) inferInstance]) : ∀ᵐ u ∂uniform01, m u ∈ Icc (0 : ℝ) 1 := by let ν : Measure ℝ := μ.map Prod.fst haveI : IsProbabilityMeasure ν := Measure.isProbabilityMeasure_map measurable_fst.aemeasurable let bad : ℝ → ℝ := fun u => if m u ∈ Icc (0 : ℝ) 1 then 0 else 1 have hcomp : (fun p : ℝ × ℝ => bad (cdf ν p.1)) =ᵐ[μ] (fun _ => (0 : ℝ)) := by filter_upwards [conditionalMean_comp_mem_Icc_ae μ hmark m hm] with p hp change (if m (cdf ν p.1) ∈ Icc (0 : ℝ) 1 then (0 : ℝ) else 1) = 0 exact if_pos hp have hfst : (fun t => bad (cdf ν t)) =ᵐ[ν] (fun _ => (0 : ℝ)) := ae_eq_of_comp_fst μ (fun t => bad (cdf ν t)) (fun _ => 0) hcomp have huni : bad =ᵐ[uniform01] (fun _ => (0 : ℝ)) := ae_eq_of_comp_continuous_cdf ν hcont bad (fun _ => 0) hfst filter_upwards [huni] with u hu by_contra hnot have hbad : bad u = 1 := if_neg hnot rw [hbad] at hu norm_num at hu
PowerApproximation 3 core · 6 supporting Order-statistic moments, the randomized adjacent-statistic coupling, and its threshold-indicator L1 estimate. ★ adjacentOrderMix_indicator_L1
Adjacent order-statistic coupling for power approximation
Order-statistic moments, the randomized adjacent-statistic coupling, and its
threshold-indicator L1 estimate. The power-density approximation is assembled
in PowerL1.
The mixture includes deterministic endpoints. Its moments follow from the single-statistic formulas, and its threshold error is controlled by the centered second moment.
For a power, the power density at a real argument is s(1-u)^(s-1).
Definition (Lean source)
A sample size, adjacent order index, and interpolation fraction determine the randomized adjacent order-statistic law: with weight 1-δ it is the law of the k-th smallest and with weight δ the law of the (k+1)-th smallest of N-1 independent unit-uniform draws, where the zeroth order statistic is read as the constant 0 and the N-th as the constant 1 (weights are truncated at zero when δ lies outside the unit interval).
Definition (Lean source)
A positive sample size, valid adjacent index, and unit-interval interpolation fraction give an integrated indicator error bounded by the mixture's root mean-square displacement: writing m = (k+δ)/N, the integral over the unit interval of the absolute difference between the CDF of the randomized adjacent order-statistic law and the step function jumping from 0 to 1 at m is at most the square root of m(1-m)/(N+1) + δ(1-δ)/(N(N+1)).
Formal statement
Proof (Lean source)
6 supporting declarations (lemmas, instances)
-
adjacentOrderMix_meantheorem — For a positive sample size, interpolation index, and unit interpolation fraction, the adjacent order-statistic mixture has mean (k+δ)/N.hypothesesconclusion∫ u, u ∂adjacentOrderMix N k δ = (k + δ) / NProof (Lean source)
theorem adjacentOrderMix_mean {N k : ℕ} (hN : 0 < N) (hk : k < N) {δ : ℝ} (hδ : δ ∈ Icc (0 : ℝ) 1) : ∫ u, u ∂adjacentOrderMix N k δ = (k + δ) / N := by haveI : IsProbabilityMeasure uniform01 := ⟨by simp [uniform01]⟩ haveI : IsProbabilityMeasure (iidSample uniform01 (N - 1)) := by dsimp [iidSample] infer_instance have hlo := (integrable_endpoint_moments (orderEndpoint_aemeasurable (N - 1) k) (orderEndpoint_mem_Icc (N - 1) k)).1 have hhi := (integrable_endpoint_moments (orderEndpoint_aemeasurable (N - 1) (k + 1)) (orderEndpoint_mem_Icc (N - 1) (k + 1))).1 rw [adjacentOrderMix_integral hN hk hδ (fun u : ℝ => u) hlo hhi, orderEndpoint_mean (N - 1) k (by omega), orderEndpoint_mean (N - 1) (k + 1) (by omega)] have hcast : ((N - 1 : ℕ) : ℝ) + 1 = N := by exact_mod_cast (show N - 1 + 1 = N by omega) rw [hcast] have hne : (N : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt hN) field_simp push_cast ring -
adjacentOrderMix_variancetheorem — For a positive sample size, interpolation index, and unit interpolation fraction, the adjacent order-statistic mixture has the stated centered second moment.hypothesesconclusion(∫ u, (u - ((k + δ) / N)) ^ 2 ∂adjacentOrderMix N k δ)= ((k + δ) / N) * (1 - (k + δ) / N) / (N + 1) + δ * (1 - δ) / (N * (N + 1))Proof (Lean source)
theorem adjacentOrderMix_variance {N k : ℕ} (hN : 0 < N) (hk : k < N) {δ : ℝ} (hδ : δ ∈ Icc (0 : ℝ) 1) : (∫ u, (u - ((k + δ) / N)) ^ 2 ∂adjacentOrderMix N k δ) = ((k + δ) / N) * (1 - (k + δ) / N) / (N + 1) + δ * (1 - δ) / (N * (N + 1)) := by haveI : IsProbabilityMeasure uniform01 := ⟨by simp [uniform01]⟩ haveI : IsProbabilityMeasure (iidSample uniform01 (N - 1)) := by dsimp [iidSample] infer_instance let μ := adjacentOrderMix N k δ let m : ℝ := (k + δ) / N have hmass : (∫ _u : ℝ, (1 : ℝ) ∂μ) = 1 := by have hmap (r : ℕ) : (∫ _u : ℝ, (1 : ℝ) ∂(iidSample uniform01 (N - 1)).map (orderEndpoint (N - 1) r)) = 1 := by rw [integral_map (orderEndpoint_aemeasurable (N - 1) r) measurable_const.aestronglyMeasurable] simp change (∫ _u : ℝ, (1 : ℝ) ∂adjacentOrderMix N k δ) = 1 rw [adjacentOrderMix_integral hN hk hδ (fun _ : ℝ => (1 : ℝ)) (integrable_const _) (integrable_const _), hmap k, hmap (k + 1)] ring have hμfinite : IsFiniteMeasure μ := by have hm : (μ univ).toReal = 1 := by simpa [integral_const, Measure.real] using hmass have hne : μ univ ≠ ⊤ := (ENNReal.toReal_ne_zero.mp (by rw [hm]; norm_num)).2 exact ⟨lt_top_iff_ne_top.mpr hne⟩ have hlo1 := (integrable_endpoint_moments (orderEndpoint_aemeasurable (N - 1) k) (orderEndpoint_mem_Icc (N - 1) k)).1 have hhi1 := (integrable_endpoint_moments (orderEndpoint_aemeasurable (N - 1) (k + 1)) (orderEndpoint_mem_Icc (N - 1) (k + 1))).1 have hlo2 := (integrable_endpoint_moments (orderEndpoint_aemeasurable (N - 1) k) (orderEndpoint_mem_Icc (N - 1) k)).2 have hhi2 := (integrable_endpoint_moments (orderEndpoint_aemeasurable (N - 1) (k + 1)) (orderEndpoint_mem_Icc (N - 1) (k + 1))).2 have hI1 : Integrable (fun u : ℝ => u) μ := by change Integrable (fun u : ℝ => u) (adjacentOrderMix N k δ) rw [adjacentOrderMix_eq_endpoints hN hk] exact (hlo1.smul_measure (by simp)).add_measure (hhi1.smul_measure (by simp)) have hI2 : Integrable (fun u : ℝ => u ^ 2) μ := by change Integrable (fun u : ℝ => u ^ 2) (adjacentOrderMix N k δ) rw [adjacentOrderMix_eq_endpoints hN hk] exact (hlo2.smul_measure (by simp)).add_measure (hhi2.smul_measure (by simp)) have hcenter : (∫ u, (u - m) ^ 2 ∂μ) = (∫ u, u ^ 2 ∂μ) - 2 * m * (∫ u, u ∂μ) + m ^ 2 := by calc (∫ u, (u - m) ^ 2 ∂μ) = ∫ u, (u ^ 2 - (2 * m) * u + m ^ 2) ∂μ := by congr 1 funext u ring _ = (∫ u, u ^ 2 ∂μ) - 2 * m * (∫ u, u ∂μ) + m ^ 2 := by have hmul : Integrable (fun u : ℝ => (2 * m) * u) μ := hI1.const_mul _ have hsub : Integrable (fun u : ℝ => u ^ 2 - (2 * m) * u) μ := hI2.sub hmul rw [integral_add hsub (integrable_const (m ^ 2)), integral_sub hI2 hmul, integral_const_mul] have hmreal : μ.real univ = 1 := by simpa [integral_const] using hmass simp [integral_const, hmreal] rw [hcenter, adjacentOrderMix_mean hN hk hδ, adjacentOrderMix_second_moment hN hk hδ] dsimp [m] have hNr : (N : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt hN) have hNr1 : (N : ℝ) + 1 ≠ 0 := by positivity field_simp push_cast ring -
integral_abs_cdf_sub_step_eq_mean_abstheorem — For a probability law supported on the unit interval and a threshold in that interval, the integrated absolute difference between its CDF and the threshold step equals its mean absolute displacement from that threshold.hypothesesProof (Lean source)
theorem integral_abs_cdf_sub_step_eq_mean_abs (ν : Measure ℝ) [IsProbabilityMeasure ν] (hsupp : ∀ᵐ x ∂ν, x ∈ Icc (0 : ℝ) 1) {t : ℝ} (ht : t ∈ Icc (0 : ℝ) 1) : (∫ u in Icc (0 : ℝ) 1, |(ν (Iic u)).toReal - (if t ≤ u then (1 : ℝ) else 0)| ∂volume) = ∫ x, |x - t| ∂ν := by have hν : ν (Icc (0 : ℝ) 1)ᶜ = 0 := (ae_iff).mp hsupp have hδ : (Measure.dirac t) (Icc (0 : ℝ) 1)ᶜ = 0 := by simp [ht] have hq : ∀ᵐ u ∂Causalean.Stat.unifOI, quantile (Measure.dirac t) u = t := by filter_upwards [quantile_mem_Icc_ae (Measure.dirac t) (by simp : (Measure.dirac t) (Icc t t)ᶜ = 0)] with u hu exact (Set.mem_Icc.mp hu).2.antisymm (Set.mem_Icc.mp hu).1 have hcost : (∫ u in (0 : ℝ)..1, |quantile ν u - quantile (Measure.dirac t) u|) = ∫ x, |x - t| ∂ν := by have hrest : volume.restrict (Ioc (0 : ℝ) 1) = unifOI := by rw [unifOI, restrict_Ioo_eq_restrict_Ioc] rw [intervalIntegral.integral_of_le (by norm_num : (0 : ℝ) ≤ 1), hrest] have hcongr : (∫ u, |quantile ν u - quantile (Measure.dirac t) u| ∂Causalean.Stat.unifOI) = ∫ u, |quantile ν u - t| ∂Causalean.Stat.unifOI := by apply integral_congr_ae filter_upwards [hq] with u hu rw [hu] calc _ = ∫ u, |quantile ν u - t| ∂Causalean.Stat.unifOI := hcongr _ = ∫ x, |x - t| ∂(Causalean.Stat.unifOI.map (quantile ν)) := by exact (integral_map (aemeasurable_quantile_unifOI ν) (show AEStronglyMeasurable (fun x : ℝ => |x - t|) (Causalean.Stat.unifOI.map (quantile ν)) from by fun_prop)).symm _ = ∫ x, |x - t| ∂ν := by rw [quantile_map_uniform] have htransport := quantile_transport_eq_cdf_distance ν (Measure.dirac t) (by norm_num : (0 : ℝ) ≤ 1) hν hδ rw [hcost] at htransport rw [htransport] rw [MeasureTheory.integral_Icc_eq_integral_Ioc, ← intervalIntegral.integral_of_le (by norm_num : (0 : ℝ) ≤ 1)] congr 1 funext u rw [ProbabilityTheory.cdf_eq_real, ProbabilityTheory.cdf_eq_real] by_cases h : t ≤ u <;> simp [Measure.real, Set.mem_Iic, h] -
adjacentOrderMix_abs_deviation_le_sqrttheorem — The mean absolute displacement of an adjacent order-statistic mixture from its interpolation threshold is bounded by its root mean-square displacement.hypothesesconclusion(∫ x, |x - ((k + δ) / N)| ∂adjacentOrderMix N k δ)≤ sqrt (((k + δ) / N) * (1 - (k + δ) / N) / (N + 1) + δ * (1 - δ) / (N * (N + 1)))Proof (Lean source)
theorem adjacentOrderMix_abs_deviation_le_sqrt {N k : ℕ} (hN : 0 < N) (hk : k < N) {δ : ℝ} (hδ : δ ∈ Icc (0 : ℝ) 1) : (∫ x, |x - ((k + δ) / N)| ∂adjacentOrderMix N k δ) ≤ sqrt (((k + δ) / N) * (1 - (k + δ) / N) / (N + 1) + δ * (1 - δ) / (N * (N + 1))) := by haveI : IsProbabilityMeasure uniform01 := ⟨by simp [uniform01]⟩ haveI : IsProbabilityMeasure (iidSample uniform01 (N - 1)) := by dsimp [iidSample] infer_instance let μ := adjacentOrderMix N k δ let m : ℝ := (k + δ) / N have hmass : (∫ _u : ℝ, (1 : ℝ) ∂μ) = 1 := by have hmap (r : ℕ) : (∫ _u : ℝ, (1 : ℝ) ∂(iidSample uniform01 (N - 1)).map (orderEndpoint (N - 1) r)) = 1 := by rw [integral_map (orderEndpoint_aemeasurable (N - 1) r) measurable_const.aestronglyMeasurable] simp change (∫ _u : ℝ, (1 : ℝ) ∂adjacentOrderMix N k δ) = 1 rw [adjacentOrderMix_integral hN hk hδ (fun _ : ℝ => (1 : ℝ)) (integrable_const _) (integrable_const _), hmap k, hmap (k + 1)] ring haveI : IsProbabilityMeasure μ := by have hreal : (μ univ).toReal = 1 := by simpa [integral_const, Measure.real] using hmass exact isProbabilityMeasure_iff_real.mpr hreal have hlo1 := (integrable_endpoint_moments (orderEndpoint_aemeasurable (N - 1) k) (orderEndpoint_mem_Icc (N - 1) k)).1 have hhi1 := (integrable_endpoint_moments (orderEndpoint_aemeasurable (N - 1) (k + 1)) (orderEndpoint_mem_Icc (N - 1) (k + 1))).1 have hlo2 := (integrable_endpoint_moments (orderEndpoint_aemeasurable (N - 1) k) (orderEndpoint_mem_Icc (N - 1) k)).2 have hhi2 := (integrable_endpoint_moments (orderEndpoint_aemeasurable (N - 1) (k + 1)) (orderEndpoint_mem_Icc (N - 1) (k + 1))).2 have hI1 : Integrable (fun u : ℝ => u) μ := by change Integrable (fun u : ℝ => u) (adjacentOrderMix N k δ) rw [adjacentOrderMix_eq_endpoints hN hk] exact (hlo1.smul_measure (by simp)).add_measure (hhi1.smul_measure (by simp)) have hI2 : Integrable (fun u : ℝ => u ^ 2) μ := by change Integrable (fun u : ℝ => u ^ 2) (adjacentOrderMix N k δ) rw [adjacentOrderMix_eq_endpoints hN hk] exact (hlo2.smul_measure (by simp)).add_measure (hhi2.smul_measure (by simp)) have hsq : Integrable (fun u : ℝ => (u - m) ^ 2) μ := by have h := (hI2.sub (hI1.const_mul (2 * m))).add (integrable_const (m ^ 2)) have hfun : (fun u : ℝ => (u - m) ^ 2) = (fun u : ℝ => u ^ 2 - (2 * m) * u + m ^ 2) := by funext u ring rw [hfun] exact h have hmeas : AEStronglyMeasurable (fun u : ℝ => u - m) μ := by fun_prop have hL2 : MemLp (fun u : ℝ => u - m) 2 μ := (memLp_two_iff_integrable_sq hmeas).2 hsq have hbound := integral_abs_le_sqrt_integral_sq μ (fun u : ℝ => u - m) hL2 have hsquared : (∫ u, |u - m| ^ 2 ∂μ) = m * (1 - m) / (N + 1) + δ * (1 - δ) / (N * (N + 1)) := by simpa only [sq_abs, m, μ] using adjacentOrderMix_variance hN hk hδ simp only [Real.norm_eq_abs, hsquared, m, μ] at hbound exact hbound -
adjacentOrderMix_indicator_L1_le_sqrt_two_t_over_Ntheorem — For a positive sample size, adjacent index, and interpolation fraction in the unit interval, the threshold-indicator error is at most the square root of twice the threshold divided by N. This coarse bound isolates the algebra needed to integrate the coupling error against the power curvature, including the deterministic endpoint cases.hypothesesconclusion(∫ u in Icc (0 : ℝ) 1, |((adjacentOrderMix N k δ) (Iic u)).toReal - (if (k + δ) / N ≤ u then (1 : ℝ) else 0)| ∂volume)≤ sqrt (2 * ((k + δ) / N) / N)Proof (Lean source)
theorem adjacentOrderMix_indicator_L1_le_sqrt_two_t_over_N {N k : ℕ} (hN : 0 < N) (hk : k < N) {δ : ℝ} (hδ : δ ∈ Icc (0 : ℝ) 1) : (∫ u in Icc (0 : ℝ) 1, |((adjacentOrderMix N k δ) (Iic u)).toReal - (if (k + δ) / N ≤ u then (1 : ℝ) else 0)| ∂volume) ≤ sqrt (2 * ((k + δ) / N) / N) := by -- Use `adjacentOrderMix_indicator_L1`, then bound its exact variance by -- `2 * t / N`: the first term is at most `t / N`, and the interpolation -- term is at most `t / N` because `δ ≤ k + δ`. have hNr : (0 : ℝ) < N := by exact_mod_cast hN have hNr1 : (0 : ℝ) < N + 1 := by positivity have ht0 : 0 ≤ (k + δ) / (N : ℝ) := by apply div_nonneg _ (le_of_lt hNr) exact add_nonneg (Nat.cast_nonneg _) hδ.1 have ht1 : (k + δ) / (N : ℝ) ≤ 1 := by apply (div_le_iff₀ hNr).2 have hk' : (k : ℝ) + 1 ≤ N := by exact_mod_cast hk linarith [hδ.2] have hδk : δ ≤ (k : ℝ) + δ := by linarith [Nat.cast_nonneg (α := ℝ) k] have hfirst : ((k + δ) / N) * (1 - (k + δ) / N) / (N + 1) ≤ ((k + δ) / N) / N := by calc _ ≤ ((k + δ) / N) / (N + 1) := by apply div_le_div_of_nonneg_right _ (le_of_lt hNr1) nlinarith [mul_nonneg ht0 (sub_nonneg.mpr ht1)] _ ≤ ((k + δ) / N) / N := by apply div_le_div_of_nonneg_left ht0 hNr linarith have hsecond : δ * (1 - δ) / (N * (N + 1)) ≤ ((k + δ) / N) / N := by calc _ ≤ δ / (N * (N + 1)) := by apply div_le_div_of_nonneg_right _ (by positivity) nlinarith [sq_nonneg δ] _ ≤ (k + δ) / (N * (N + 1)) := by apply div_le_div_of_nonneg_right hδk (by positivity) _ ≤ (k + δ) / (N * N) := by apply div_le_div_of_nonneg_left (add_nonneg (Nat.cast_nonneg _) hδ.1) (by positivity) nlinarith [sq_nonneg (N : ℝ)] _ = ((k + δ) / N) / N := by ring calc _ ≤ sqrt (((k + δ) / N) * (1 - (k + δ) / N) / (N + 1) + δ * (1 - δ) / (N * (N + 1))) := adjacentOrderMix_indicator_L1 hN hk hδ _ ≤ _ := by apply Real.sqrt_le_sqrt have htwo : ((k + δ) / (N : ℝ)) / N + ((k + δ) / N) / N = 2 * ((k + δ) / N) / N := by ring rw [← htwo] exact add_le_add hfirst hsecond -
integral_powerDensitytheorem — For a real power at least one, the power density integrates to one over the unit interval.Proof (Lean source)
theorem integral_powerDensity {s : ℝ} (hs : 1 ≤ s) : (∫ u in Icc (0 : ℝ) 1, powerDensity s u ∂volume) = 1 := by have h := powerCell_eq_integral (N := 1) (by omega) hs (0 : Fin 1) have hcell : powerCell 1 s (0 : Fin 1) = 1 := by simp [powerCell, Real.zero_rpow (by linarith : s ≠ 0)] rw [hcell] at h simpa [powerDensity, intervalIntegral.integral_of_le, ← integral_Icc_eq_integral_Ioc] using h.symm
PowerCells 2 core · 5 supporting Finite cells of the decreasing power density and their algebraic bounds. ★ sum_powerCell_sq_le
Power cell masses
Finite cells of the decreasing power density and their algebraic bounds.
Proof route: the sum telescopes; the integral identity follows from the real
power antiderivative on each cell, including the rightmost endpoint by
continuity. Monotonicity follows from the decreasing derivative for s ≥ 1.
The first-cell bound is Bernoulli's inequality, then nonnegativity,
antitonicity, and unit sum give the square-sum bound.
For a cell index, sample size, and power, the power cell mass is the drop of the power survival function across that cell.
Definition (Lean source)
For a positive sample size and power at least one, the sum of squared power cell masses is at most the power divided by sample size.
Formal statement
Proof (Lean source)
5 supporting declarations (lemmas, instances)
-
powerCell_nonnegtheorem — For a power at least one, power cells are nonnegative.Proof (Lean source)
theorem powerCell_nonneg {N : ℕ} {s : ℝ} (hs : 1 ≤ s) (j : Fin N) : 0 ≤ powerCell N s j := by have hN : (0 : ℝ) < N := by exact_mod_cast Nat.zero_lt_of_lt j.isLt have hj : ((j : ℕ) : ℝ) + 1 ≤ N := by exact_mod_cast j.isLt have hleft : 0 ≤ 1 - ((j : ℝ) + 1) / N := by apply sub_nonneg.mpr exact (div_le_one hN).2 hj have horder : 1 - ((j : ℝ) + 1) / N ≤ 1 - (j : ℝ) / N := by have hdiv : (j : ℝ) / N ≤ ((j : ℝ) + 1) / N := div_le_div_of_nonneg_right (by linarith) hN.le linarith unfold powerCell exact sub_nonneg.mpr (Real.rpow_le_rpow hleft horder (by linarith)) -
powerCell_antitonetheorem — For a power at least one, power cell masses decrease with the cell index.Proof (Lean source)
theorem powerCell_antitone {N : ℕ} {s : ℝ} (hs : 1 ≤ s) : Antitone (powerCell N s) := by cases N with | zero => intro j; exact elim0 j | succ n => apply Fin.antitone_iff_succ_le.mpr intro i let a : ℝ := 1 - ((i : ℕ) + 2 : ℝ) / (n + 1) let b : ℝ := 1 - ((i : ℕ) + 1 : ℝ) / (n + 1) let c : ℝ := 1 - (i : ℝ) / (n + 1) have hn : (0 : ℝ) < (n + 1 : ℕ) := by positivity have ha : 0 ≤ a := by have hi : (i : ℕ) + 2 ≤ n + 1 := by omega have hi' : (((i : ℕ) + 2 : ℕ) : ℝ) ≤ (n + 1 : ℕ) := by exact_mod_cast hi simpa only [Nat.cast_add, Nat.cast_one, Nat.cast_ofNat] using (sub_nonneg.mpr ((div_le_one hn).2 hi')) have hc : 0 ≤ c := by have hi : (i : ℕ) ≤ n + 1 := by omega have hi' : ((i : ℕ) : ℝ) ≤ (n + 1 : ℕ) := by exact_mod_cast hi simpa only [Nat.cast_add, Nat.cast_one] using (sub_nonneg.mpr ((div_le_one hn).2 hi')) have hm : b = (1 / 2 : ℝ) • a + (1 / 2 : ℝ) • c := by dsimp [a, b, c] ring have hconv := (convexOn_rpow hs).2 ha hc (show (0 : ℝ) ≤ 1 / 2 by norm_num) (show (0 : ℝ) ≤ 1 / 2 by norm_num) (by norm_num : (1 / 2 : ℝ) + 1 / 2 = 1) rw [← hm] at hconv simp only [smul_eq_mul] at hconv have hstep : b ^ s - a ^ s ≤ c ^ s - b ^ s := by linarith convert hstep using 1 all_goals first | rfl | (simp [powerCell, a, b, c, succ, castSucc, Nat.cast_add, add_assoc] <;> ring) -
sum_powerCelltheorem — For a positive sample size and power at least one, the power cell masses sum to one.Proof (Lean source)
theorem sum_powerCell {N : ℕ} (hN : 0 < N) {s : ℝ} (hs : 1 ≤ s) : ∑ j : Fin N, powerCell N s j = 1 := by let f : ℕ → ℝ := fun i => (1 - (i : ℝ) / N) ^ s have hsum : (∑ j : Fin N, powerCell N s j) = ∑ i ∈ range N, (f i - f (i + 1)) := by rw [← Fin.sum_univ_eq_sum_range] apply Finset.sum_congr rfl intro j _ simp only [powerCell, f, Nat.cast_add, Nat.cast_one] rw [hsum, Finset.sum_range_sub'] simp [f, ne_of_gt hN, Real.zero_rpow (by linarith : s ≠ 0)] -
powerCell_zero_letheorem — For a positive sample size and power at least one, the first cell mass is at most the power divided by sample size.Proof (Lean source)
theorem powerCell_zero_le {N : ℕ} (hN : 0 < N) {s : ℝ} (hs : 1 ≤ s) : powerCell N s ⟨0, hN⟩ ≤ s / N := by have hNr : (0 : ℝ) < N := by exact_mod_cast hN have hb : -1 ≤ -(1 / (N : ℝ)) := by have : (1 : ℝ) ≤ N := by exact_mod_cast hN have : (1 : ℝ) / N ≤ 1 := (div_le_one hNr).2 this linarith have h := one_add_mul_self_le_rpow_one_add hb hs have h' : 1 - s / (N : ℝ) ≤ (1 - 1 / (N : ℝ)) ^ s := by convert h using 1 <;> ring have h'' : 1 - (1 - 1 / (N : ℝ)) ^ s ≤ s / N := by linarith simpa [powerCell] using h'' -
powerCell_eq_integraltheorem — For a positive sample size, power at least one, and cell, the power cell mass is the integral of the power density over that cell.hypothesesconclusionpowerCell N s j = ∫ u in (j : ℝ) / N..(((j : ℕ) + 1 : ℝ) / N), s * (1 - u) ^ (s - 1)Proof (Lean source)
theorem powerCell_eq_integral {N : ℕ} (hN : 0 < N) {s : ℝ} (hs : 1 ≤ s) (j : Fin N) : powerCell N s j = ∫ u in (j : ℝ) / N..(((j : ℕ) + 1 : ℝ) / N), s * (1 - u) ^ (s - 1) := by let a : ℝ := (j : ℝ) / N let b : ℝ := ((j : ℕ) + 1 : ℝ) / N let f : ℝ → ℝ := fun u => -((1 - u) ^ s) let g : ℝ → ℝ := fun u => s * (1 - u) ^ (s - 1) have hN' : (0 : ℝ) < N := by exact_mod_cast hN have hab : a ≤ b := by dsimp [a, b] apply div_le_div_of_nonneg_right _ hN'.le linarith have hf : Continuous f := by exact ((Real.continuous_rpow_const (by linarith : 0 ≤ s)).comp (continuous_const.sub continuous_id)).neg have hg : Continuous g := by exact continuous_const.mul ((Real.continuous_rpow_const (by linarith : 0 ≤ s - 1)).comp (continuous_const.sub continuous_id)) have hderiv : ∀ x ∈ Ioo a b, HasDerivAt f (g x) x := by intro x hx have hb1 : b ≤ 1 := by dsimp [b] apply (div_le_one hN').2 have : (j : ℕ) + 1 ≤ N := j.isLt exact_mod_cast this have hx1 : x < 1 := lt_of_lt_of_le hx.2 hb1 have hlin : HasDerivAt (fun u : ℝ => 1 - u) (-1) x := by convert (hasDerivAt_const x (1 : ℝ)).sub (hasDerivAt_id x) using 1 all_goals first | rfl | ring have hpow := (Real.hasDerivAt_rpow_const (x := 1 - x) (p := s) (inl (by linarith : 1 - x ≠ 0))).comp x hlin convert hpow.neg using 1 all_goals first | rfl | (dsimp [g]; ring) have hInt : IntervalIntegrable g volume a b := hg.continuousOn.intervalIntegrable_of_Icc hab have h := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le hab hf.continuousOn hderiv hInt dsimp [f, g] at h dsimp [powerCell, a, b] convert h.symm using 1 <;> ring
PowerCurvature 3 core · 4 supporting The curvature representation of a real power supplies the integrable threshold weight and the hinge-cell increment used in the finite Bernstein L1 estimate. ★ integral_powerCurvature_mul_sqrt_le
Curvature and hinge cells for real power weights
The curvature representation of a real power supplies the integrable threshold weight and the hinge-cell increment used in the finite Bernstein L1 estimate.
For a sample size, threshold, and cell, the cell increment of the positive-part hinge at that threshold is the difference between its values at the cell endpoints.
For a real power and threshold, the curvature density of the power CDF is s(s-1)(1-t)^(s-2).
Definition (Lean source)
A real power above one has a curvature-weighted square-root integral bounded by the square root of that power.
Formal statement
Proof (Lean source)
4 supporting declarations (lemmas, instances)
-
hingeCell_eq_piecewisetheorem — For a positive sample size, a hinge-cell increment is its full width below the cell, the remaining width inside it, and zero above it.hypothesesconclusionhingeCell N t j= if t ≤ ((j : ℕ) : ℝ) / (N : ℝ) then (1 : ℝ) / (N : ℝ) else if t ≤ (((j : ℕ) : ℝ) + 1) / N then (((j : ℕ) : ℝ) + 1) / N- t else (0 : ℝ)Proof (Lean source)
theorem hingeCell_eq_piecewise {N : ℕ} (hN : 0 < N) (t : ℝ) (j : Fin N) : hingeCell N t j = if t ≤ ((j : ℕ) : ℝ) / (N : ℝ) then (1 : ℝ) / (N : ℝ) else if t ≤ (((j : ℕ) : ℝ) + 1) / N then (((j : ℕ) : ℝ) + 1) / N - t else (0 : ℝ) := by have hNr : (0 : ℝ) < N := by exact_mod_cast hN have hw : (((j : ℕ) : ℝ) / N) ≤ (((j : ℕ) : ℝ) + 1) / N := by apply (div_le_div_iff_of_pos_right hNr).2 linarith unfold hingeCell split_ifs with hleft hmid · rw [max_eq_left (by linarith : 0 ≤ ((((j : ℕ) : ℝ) + 1) / N) - t), max_eq_left (by linarith : 0 ≤ (((j : ℕ) : ℝ) / N) - t)] field_simp ring · rw [max_eq_left (by linarith : 0 ≤ ((((j : ℕ) : ℝ) + 1) / N) - t), max_eq_right (by linarith : (((j : ℕ) : ℝ) / N) - t ≤ 0)] ring · rw [max_eq_right (by linarith : ((((j : ℕ) : ℝ) + 1) / N) - t ≤ 0), max_eq_right (by linarith : (((j : ℕ) : ℝ) / N) - t ≤ 0)] ring -
integral_powerCurvature_Icctheorem — For a power above one, integrating its curvature from zero to a point in the unit interval gives the drop of the power density from its initial value.hypothesesconclusionProof (Lean source)
theorem integral_powerCurvature_Icc {s u : ℝ} (hs : 1 < s) (hu : u ∈ Icc (0 : ℝ) 1) : (∫ t in Icc (0 : ℝ) u, powerCurvature s t ∂volume) = s - powerDensity s u := by have hpow : -1 < s - 2 := by linarith rw [integral_Icc_eq_integral_Ioc, ← intervalIntegral.integral_of_le hu.1] simp only [powerCurvature, powerDensity] rw [intervalIntegral.integral_const_mul] rw [intervalIntegral.integral_comp_sub_left (fun x : ℝ => x ^ (s - 2)) 1] simp only [sub_zero] rw [integral_rpow (a := 1 - u) (b := 1) (r := s - 2) (inl hpow)] simp only [Real.one_rpow] have hs0 : s - 1 ≠ 0 := by linarith have he : s - 2 + 1 = s - 1 := by ring rw [he] field_simp -
integral_powerCurvature_unittheorem — For a real power above one, the curvature density has total mass s on the unit interval.Proof (Lean source)
theorem integral_powerCurvature_unit {s : ℝ} (hs : 1 < s) : (∫ t in Icc (0 : ℝ) 1, powerCurvature s t ∂volume) = s := by rw [integral_powerCurvature_Icc hs (by norm_num)] simp [powerDensity, Real.zero_rpow (by linarith : s - 1 ≠ 0)] -
integral_mul_powerCurvature_unittheorem — For a real power above one, the first moment of its curvature density on the unit interval is one.Proof (Lean source)
theorem integral_mul_powerCurvature_unit {s : ℝ} (hs : 1 < s) : (∫ t in Icc (0 : ℝ) 1, t * powerCurvature s t ∂volume) = 1 := by have hp : -1 < s - 2 := by linarith have hq : -1 < s - 1 := by linarith have hp0 : s - 1 ≠ 0 := by linarith have hq0 : s ≠ 0 := by linarith calc (∫ t in Icc (0 : ℝ) 1, t * powerCurvature s t ∂volume) = ∫ t in (0 : ℝ)..1, t * (s * (s - 1) * (1 - t) ^ (s - 2)) := by rw [integral_Icc_eq_integral_Ioc, ← intervalIntegral.integral_of_le (by norm_num : (0 : ℝ) ≤ 1)] rfl _ = ∫ x in (0 : ℝ)..1, (1 - x) * (s * (s - 1) * x ^ (s - 2)) := by convert intervalIntegral.integral_comp_sub_left (fun x : ℝ => (1 - x) * (s * (s - 1) * x ^ (s - 2))) 1 (a := 0) (b := 1) using 1 <;> simp _ = ∫ x in (0 : ℝ)..1, (s * (s - 1)) * (x ^ (s - 2) - x ^ (s - 1)) := by apply intervalIntegral.integral_congr intro x hx have hx0 : 0 ≤ x := by have hx' : x ∈ Icc (0 : ℝ) 1 := by simpa only [Set.uIcc_of_le (by norm_num : (0 : ℝ) ≤ 1)] using hx exact hx'.1 have hpow : x ^ (s - 1) = x ^ (s - 2) * x := by rw [show s - 1 = s - 2 + 1 by ring, Real.rpow_add_one' hx0 (by linarith : s - 2 + 1 ≠ 0)] change (1 - x) * (s * (s - 1) * x ^ (s - 2)) = (s * (s - 1)) * (x ^ (s - 2) - x ^ (s - 1)) rw [hpow] ring _ = (s * (s - 1)) * ((∫ x in (0 : ℝ)..1, x ^ (s - 2)) - (∫ x in (0 : ℝ)..1, x ^ (s - 1))) := by rw [intervalIntegral.integral_const_mul, intervalIntegral.integral_sub (intervalIntegral.intervalIntegrable_rpow' hp) (intervalIntegral.intervalIntegrable_rpow' hq)] _ = 1 := by rw [integral_rpow (a := 0) (b := 1) (r := s - 2) (inl hp), integral_rpow (a := 0) (b := 1) (r := s - 1) (inl hq)] have he : s - 2 + 1 = s - 1 := by ring have he' : s - 1 + 1 = s := by ring rw [he, he'] simp [Real.zero_rpow hp0, Real.zero_rpow hq0] field_simp ring
ReplacementSensitivity 2 core · 3 supporting Exact removal and insertion positions for a replaced observation, followed by tensorized variance under an iid marked sample law. ★ rankConcomitant_replacement_sensitivity
Replacement sensitivity and variance of rank concomitants
Exact removal and insertion positions for a replaced observation, followed by tensorized variance under an iid marked sample law.
Proof route: remove the tagged point, compare the two ordered lists of the remaining points, then insert the old and new marks at their exact ranks. Antitonicity makes all intermediate weight increments one-signed and telescoping. Under continuous CDF transport, all coordinates and independent replacements avoid ties almost surely. Apply the existing tensor variance theorem and use rank exchangeability to sum the squared weights.
For a marked sample and observation index, the zero-based rank position is the inverse sorting permutation evaluated at that index.
For rank weights that are nonnegative and decrease with rank, an original sample, selected coordinate, and replacement with unit-bounded marks, distinct original coordinates, and distinct coordinates after replacement, the statistic changes by at most the removal and insertion weights.
Formal statement
Proof (Lean source)
3 supporting declarations (lemmas, instances)
-
rankPosition_val_eq_card_lttheorem — For distinct sorting coordinates, the zero-based rank of a tagged observation is the number of observations with a smaller coordinate.hypothesesconclusion(rankPosition x i).valProof (Lean source)
theorem rankPosition_val_eq_card_lt {N : ℕ} (x : Fin N → ℝ × ℝ) (i : Fin N) (hinj : Injective (fun j => (x j).1)) : (rankPosition x i).val = ((Finset.univ : Finset (Fin N)).filter (fun j => (x j).1 < (x i).1)).card := by classical let f : Fin N → ℝ := fun j => (x j).1 let σ := Tuple.sort f have hs : StrictMono (f ∘ σ) := (Tuple.monotone_sort f).strictMono_of_injective (hinj.comp σ.injective) have hcard : ((Finset.univ : Finset (Fin N)).filter (fun j => f j < f i)).card = ((Finset.univ : Finset (Fin N)).filter (fun j => j < σ.symm i)).card := by apply Finset.card_equiv σ.symm intro j simp only [mem_filter, Finset.mem_univ, true_and] simpa only [Function.comp_apply, Equiv.apply_symm_apply] using (hs.lt_iff_lt (a := σ.symm j) (b := σ.symm i)) rw [hcard] change (σ.symm i).val = ((Finset.univ : Finset (Fin N)).filter (fun j : Fin N => j.val < (σ.symm i).val)).card rw [Fin.card_filter_val_lt] exact (Nat.min_eq_right (le_of_lt (σ.symm i).isLt)).symm -
rankConcomitant_memLp_twotheorem — For an iid marked observation law with unit-bounded marks, a rank-weighted concomitant has a square-integrable law.hypothesesconclusionProof (Lean source)
theorem rankConcomitant_memLp_two {N : ℕ} (μ : Measure (ℝ × ℝ)) [IsProbabilityMeasure μ] (hmark : ∀ᵐ p ∂μ, p.2 ∈ Icc (0 : ℝ) 1) (a : Fin N → ℝ) : MemLp (rankConcomitant a) 2 (Measure.pi (fun _ : Fin N => μ)) := by classical let P : Measure (Fin N → ℝ × ℝ) := Measure.pi (fun _ : Fin N => μ) letI : MeasurableSpace (Perm (Fin N)) := ⊤ have hsort : Measurable (fun x : Fin N → ℝ × ℝ => sort (fun i => (x i).1)) := by apply measurable_to_countable' intro σ have hEq : {x : Fin N → ℝ × ℝ | sort (fun i => (x i).1) = σ} = {x | Monotone ((fun i => (x i).1) ∘ σ) ∧ ∀ i j : Fin N, i < j → (x (σ i)).1 = (x (σ j)).1 → σ i < σ j} := by ext x simpa only [Set.mem_setOf_eq, eq_comm] using (Tuple.eq_sort_iff (f := fun i => (x i).1) (σ := σ)) rw [show (fun x : Fin N → ℝ × ℝ => sort (fun i => (x i).1)) ⁻¹' {σ} = {x | sort (fun i => (x i).1) = σ} by rfl, hEq] apply MeasurableSet.inter · change MeasurableSet {x : Fin N → ℝ × ℝ | ∀ i j : Fin N, i ≤ j → (x (σ i)).1 ≤ (x (σ j)).1} have hh : MeasurableSet (⋂ i : Fin N, ⋂ j : Fin N, {x : Fin N → ℝ × ℝ | i ≤ j → (x (σ i)).1 ≤ (x (σ j)).1}) := by apply MeasurableSet.iInter intro i apply MeasurableSet.iInter intro j by_cases hij : i ≤ j · simpa only [hij, true_implies, Function.comp_apply] using measurableSet_le (measurable_fst.comp (measurable_pi_apply (σ i))) (measurable_fst.comp (measurable_pi_apply (σ j))) · simp [hij] simpa only [Set.iInter_setOf] using hh · change MeasurableSet {x : Fin N → ℝ × ℝ | ∀ i j : Fin N, i < j → (x (σ i)).1 = (x (σ j)).1 → σ i < σ j} have hh : MeasurableSet (⋂ i : Fin N, ⋂ j : Fin N, {x : Fin N → ℝ × ℝ | i < j → (x (σ i)).1 = (x (σ j)).1 → σ i < σ j}) := by apply MeasurableSet.iInter intro i apply MeasurableSet.iInter intro j by_cases hij : i < j · by_cases hσ : σ i < σ j · simp [hσ] · have heq : MeasurableSet {x : Fin N → ℝ × ℝ | (x (σ i)).1 = (x (σ j)).1} := by simpa only [Function.comp_apply] using (measurableSet_eq_fun (measurable_fst.comp (measurable_pi_apply (σ i))) (measurable_fst.comp (measurable_pi_apply (σ j)))) convert heq.compl using 1 <;> ext x <;> simp [hij, hσ] · simp [hij] simpa only [Set.iInter_setOf] using hh have hstat : Measurable (rankConcomitant a : (Fin N → ℝ × ℝ) → ℝ) := by unfold rankConcomitant apply Finset.measurable_sum intro j _ apply measurable_const.mul have hsel : Measurable (fun x : Fin N → ℝ × ℝ => ∑ i : Fin N, if sort (fun k => (x k).1) j = i then (x i).2 else 0) := by apply Finset.measurable_sum intro i _ apply Measurable.ite · exact measurableSet_eq_fun ((measurable_of_finite (fun σ : Perm (Fin N) => σ j)).comp hsort) measurable_const · exact measurable_snd.comp (measurable_pi_apply i) · exact measurable_const convert hsel using 1 funext x simp have hcoord (i : Fin N) : ∀ᵐ x ∂P, (x i).2 ∈ Icc (0 : ℝ) 1 := by exact (Measure.tendsto_eval_ae_ae (μ := fun _ : Fin N => μ) (i := i)).eventually hmark have hbound : ∀ᵐ x ∂P, ‖rankConcomitant a x‖ ≤ ∑ j : Fin N, |a j| := by have hall : ∀ᵐ x ∂P, ∀ i : Fin N, (x i).2 ∈ Icc (0 : ℝ) 1 := by exact Filter.eventually_all.mpr hcoord filter_upwards [hall] with x hx rw [Real.norm_eq_abs] calc |rankConcomitant a x| ≤ ∑ j : Fin N, |a j * (x (sort (fun i => (x i).1) j)).2| := by exact Finset.abs_sum_le_sum_abs _ _ _ ≤ ∑ j : Fin N, |a j| := by apply Finset.sum_le_sum intro j _ rw [abs_mul] have hm := hx (sort (fun i => (x i).1) j) have habs : |(x (sort (fun i => (x i).1) j)).2| ≤ 1 := by rw [abs_le] constructor <;> linarith [hm.1, hm.2] nlinarith [abs_nonneg (a j)] exact MemLp.of_bound hstat.aestronglyMeasurable _ hbound -
integral_rankPosition_weight_sqtheorem — For a positive iid sample size and continuous sorting-coordinate CDF, each tagged observation has uniform rank, so its squared rank weight averages to the mean squared cell weight.hypothesesconclusion(∫ x, (a (rankPosition x i)) ^ 2 ∂Measure.pi (fun _ : Fin N => μ))= (∑ j : Fin N, (a j) ^ 2) / NProof (Lean source)
theorem integral_rankPosition_weight_sq {N : ℕ} (hN : 0 < N) (μ : Measure (ℝ × ℝ)) [IsProbabilityMeasure μ] (hcont : Continuous (fun t => cdf (μ.map fst) t)) (a : Fin N → ℝ) (i : Fin N) : (∫ x, (a (rankPosition x i)) ^ 2 ∂Measure.pi (fun _ : Fin N => μ)) = (∑ j : Fin N, (a j) ^ 2) / N := by -- Transport to iid uniforms and integrate over the finite rank partition. classical let P : Measure (Fin N → ℝ × ℝ) := Measure.pi (fun _ : Fin N => μ) let Q : Measure (Fin N → ℝ) := Causalean.Stat.OrderStatistic.iidSample Causalean.Stat.OrderStatistic.uniform01 N let F : (Fin N → ℝ × ℝ) → (Fin N → ℝ) := fun x k => cdf (μ.map fst) (x k).1 let r : (Fin N → ℝ) → Fin N := fun u => (sort u).symm i have hF : Measurable F := by apply measurable_pi_iff.mpr intro k exact hcont.measurable.comp (measurable_fst.comp (measurable_pi_apply k)) have hrank (j : Fin N) : NullMeasurableSet {u | r u = j} Q := by let E : Set (Fin N → ℝ) := {u | (((Finset.univ : Finset (Fin N)).erase i).filter (fun k => u k < u i)).card = j.val} have hE : MeasurableSet E := by dsimp [E] apply measurableSet_eq_fun · simp_rw [Finset.card_filter] apply Finset.measurable_sum intro k _ apply Measurable.ite · exact measurableSet_lt (measurable_pi_apply k) (measurable_pi_apply i) · exact measurable_const · exact measurable_const · exact measurable_const apply hE.nullMeasurableSet.congr filter_upwards [iid_uniform_coordinates_injective_ae (N := N)] with u hu apply propext change (((Finset.univ : Finset (Fin N)).erase i).filter (fun k => u k < u i)).card = j.val ↔ r u = j rw [← uniform_tagged_rank_eq_count u i hu] exact Fin.ext_iff.symm have hr : AEMeasurable r Q := by apply NullMeasurable.aemeasurable change @Measurable (NullMeasurableSpace (Fin N → ℝ) Q) (Fin N) _ _ r apply measurable_to_countable' intro j exact hrank j have htransport : P.map F = Q := cdf_transport_iid μ hcont have hmass (j : Fin N) : (Q.map r) {j} = ofReal (1 / (N : ℝ)) := by rw [Measure.map_apply₀ hr (measurableSet_singleton j).nullMeasurableSet] exact uniform_tagged_rank_mass hN i j haveI : IsProbabilityMeasure Q := by haveI : IsProbabilityMeasure Causalean.Stat.OrderStatistic.uniform01 := ⟨by simp [Causalean.Stat.OrderStatistic.uniform01]⟩ dsimp [Q, Causalean.Stat.OrderStatistic.iidSample] infer_instance haveI : IsProbabilityMeasure (Q.map r) := Measure.isProbabilityMeasure_map hr have hfin : Integrable (fun j : Fin N => (a j) ^ 2) (Q.map r) := Integrable.of_finite calc (∫ x, (a (rankPosition x i)) ^ 2 ∂P) = ∫ x, (a (r (F x))) ^ 2 ∂P := by apply integral_congr_ae filter_upwards [sort_cdf_eq_ae μ hcont] with x hx simp only [rankPosition, r, F, hx] _ = ∫ u, (a (r u)) ^ 2 ∂Q := by have hstrong : AEStronglyMeasurable (fun u => (a (r u)) ^ 2) Q := ((measurable_of_countable (fun j : Fin N => (a j) ^ 2)).comp_aemeasurable hr).aestronglyMeasurable rw [← htransport] rw [← htransport] at hstrong exact (integral_map hF.aemeasurable hstrong).symm _ = ∫ j, (a j) ^ 2 ∂Q.map r := by exact (integral_map hr ((measurable_of_countable (fun j : Fin N => (a j) ^ 2)).aestronglyMeasurable)).symm _ = (∑ j : Fin N, (a j) ^ 2) / N := by rw [integral_fintype hfin] have hnonneg : 0 ≤ (1 / (N : ℝ)) := by positivity simp only [Measure.real, hmass, ENNReal.toReal_ofReal hnonneg, smul_eq_mul] rw [← Finset.mul_sum] ring
AeDescent 1 core · 2 supporting These two measure-transport facts isolate the descent of an equality of possibly nonmeasurable versions. ★ ae_eq_of_comp_continuous_cdf
Almost-everywhere descent through a marginal and a continuous CDF
These two measure-transport facts isolate the descent of an equality of possibly nonmeasurable versions. The target equality itself must be proved almost everywhere; no global measurability of either version is assumed.
A real probability law with a continuous CDF carries two real functions that agree after CDF composition to agreement under the unit-uniform law.
Formal statement
Proof (Lean source)
2 supporting declarations (lemmas, instances)
-
fst_null_of_preimage_nulltheorem — For a probability law on real pairs, a set of first-coordinate values whose full inverse image is null is itself null under the first marginal.hypothesesconclusion(μ.map fst) s = 0Proof (Lean source)
theorem fst_null_of_preimage_null (μ : Measure (ℝ × ℝ)) [IsProbabilityMeasure μ] (s : Set ℝ) (hs : μ (fst ⁻¹' s) = 0) : (μ.map fst) s = 0 := by obtain ⟨t, hst, htm, ht0⟩ := exists_measurable_superset_of_null hs let u : Set ℝ := {x | μ.condKernel x {y | (x, y) ∈ t} ≠ 0} have hF : Measurable (fun x => μ.condKernel x {y | (x, y) ∈ t}) := ProbabilityTheory.Kernel.measurable_kernel_prodMk_left (κ := μ.condKernel) htm have hu : MeasurableSet u := (measurableSet_singleton (0 : ENNReal)).compl.preimage hF have hsu : s ⊆ u := by intro x hx have hf : {y : ℝ | (x, y) ∈ t} = univ := by ext y simp only [Set.mem_ofPred_eq, Set.mem_univ, iff_true] exact hst hx simp only [u, Set.mem_ofPred_eq, hf] simp have hu0 : μ.fst u = 0 := by have hi : (∫⁻ x, μ.condKernel x {y | (x, y) ∈ t} ∂μ.fst) = 0 := by rw [μ.lintegral_condKernel_mem htm, ht0] have hae := (lintegral_eq_zero_iff hF).mp hi exact (ae_iff).mp (hae.mono fun x hx => by change μ.condKernel x {y | (x, y) ∈ t} = 0 at hx exact hx) apply le_antisymm _ zero_le calc (μ.map fst) s ≤ (μ.map fst) u := measure_mono hsu _ = μ.fst u := rfl _ = 0 := hu0 -
ae_eq_of_comp_fsttheorem — If two real functions of the first coordinate agree almost surely under a probability law on real pairs, then they agree almost surely under its first marginal.hypothesesconclusionf =ᵐ[μ.map fst] gProof (Lean source)
theorem ae_eq_of_comp_fst (μ : Measure (ℝ × ℝ)) [IsProbabilityMeasure μ] (f g : ℝ → ℝ) (h : (fun p : ℝ × ℝ => f p.1) =ᵐ[μ] (fun p => g p.1)) : f =ᵐ[μ.map fst] g := by apply (ae_iff).2 exact fst_null_of_preimage_null μ {t | f t ≠ g t} (by simpa only [Set.preimage_setOf_eq, ne_eq] using (ae_iff).mp h)
ConcomitantExpectation 1 core · 1 supporting This module turns the tagged conditional-mean identity into the Bernstein-kernel expectation formula for a complete finite marked sample. ★ integral_rankConcomitant_eq_bernstein
Bernstein expectation of rank-weighted concomitants
This module turns the tagged conditional-mean identity into the Bernstein-kernel expectation formula for a complete finite marked sample.
For positive sample size, marked observation law, continuous sorting-coordinate CDF, bounded marks, cell weights, and a conditional mean version, the expected concomitant equals the Bernstein integral.
Formal statement
Proof (Lean source)
1 supporting declaration (lemmas, instances)
-
integral_rankConcomitant_eq_conditionalMeantheorem — For a bounded marked iid law, continuous coordinate CDF, cell weights, and a conditional mean function and version, conditioning replaces each sorted mark by that mean in the expected rank concomitant.hypothesesProof (Lean source)
theorem integral_rankConcomitant_eq_conditionalMean {N : ℕ} (μ : Measure (ℝ × ℝ)) [IsProbabilityMeasure μ] (hcont : Continuous (fun t => cdf (μ.map fst) t)) (hmark : ∀ᵐ p ∂μ, p.2 ∈ Icc (0 : ℝ) 1) (a : Fin N → ℝ) (m : ℝ → ℝ) (hm : (fun p : ℝ × ℝ => m (cdf (μ.map fst) p.1)) =ᵐ[μ] μ[(fun p : ℝ × ℝ => p.2) | comap (fun p : ℝ × ℝ => cdf (μ.map fst) p.1) inferInstance]) : (∫ x, rankConcomitant a x ∂Measure.pi (fun _ : Fin N => μ)) = ∫ x, (∑ j : Fin N, a j * m (cdf (μ.map fst) (x (sort (fun i => (x i).1) j)).1)) ∂Measure.pi (fun _ : Fin N => μ) := by -- Expand the finite sum, condition each tagged mark on its CDF coordinate, -- and use `sort_cdf_eq_ae` to make the rank event coordinate-measurable. classical let ν : Measure (Fin N → ℝ × ℝ) := Measure.pi (fun _ => μ) let F : ℝ × ℝ → ℝ := fun p => cdf (μ.map fst) p.1 have hF : Measurable F := hcont.measurable.comp measurable_fst have hinj : ∀ᵐ x ∂ν, Injective (fun k => F (x k)) := by have hu := iid_uniform_coordinates_injective_ae (N := N) rw [← cdf_transport_iid μ hcont] at hu exact ae_of_ae_map (by apply aemeasurable apply measurable_pi_iff.mpr intro k exact hF.comp (measurable_pi_apply k) : AEMeasurable (fun x : Fin N → ℝ × ℝ => fun k => F (x k)) ν) hu have hC (i j : Fin N) : MeasurableSet {x : Fin N → ℝ × ℝ | (((Finset.univ : Finset (Fin N)).erase i).filter (fun k => F (x k) < F (x i))).card = j.val} := by apply measurableSet_eq_fun · simp_rw [Finset.card_filter] apply Finset.measurable_sum intro k _ apply Measurable.ite · exact measurableSet_lt (hF.comp (measurable_pi_apply k)) (hF.comp (measurable_pi_apply i)) · exact measurable_const · exact measurable_const · exact measurable_const have hrank (i j : Fin N) : ∀ᵐ x ∂ν, (((sort (fun k => (x k).1)).symm i = j) ↔ (((Finset.univ : Finset (Fin N)).erase i).filter (fun k => F (x k) < F (x i))).card = j.val) := by filter_upwards [sort_cdf_eq_ae μ hcont, hinj] with x hs hx rw [hs, ← uniform_tagged_rank_eq_count (fun k => F (x k)) i hx] exact Fin.ext_iff obtain ⟨g, hg, hmg⟩ := conditionalMean_exists_measurable_version μ m hm have hgbound : ∀ᵐ p ∂μ, |g (F p)| ≤ 1 := by filter_upwards [conditionalMean_comp_mem_Icc_ae μ hmark m hm, hmg] with p hp he rw [he] at hp exact abs_le.mpr ⟨by linarith [hp.1], hp.2⟩ have hmarkBound (i : Fin N) : ∀ᵐ x ∂ν, |(x i).2| ≤ 1 := by have hbμ : ∀ᵐ p ∂μ, |p.2| ≤ 1 := hmark.mono fun p hp => abs_le.mpr ⟨by linarith [hp.1], hp.2⟩ exact ae_of_ae_map (μ := ν) (f := fun x : Fin N → ℝ × ℝ => x i) (p := fun p => |p.2| ≤ 1) (measurable_pi_apply i).aemeasurable (by rw [(measurePreserving_eval (fun _ : Fin N => μ) i).map_eq] exact hbμ) have hgBound (i : Fin N) : ∀ᵐ x ∂ν, |g (F (x i))| ≤ 1 := by exact ae_of_ae_map (μ := ν) (f := fun x : Fin N → ℝ × ℝ => x i) (p := fun p => |g (F p)| ≤ 1) (measurable_pi_apply i).aemeasurable (by rw [(measurePreserving_eval (fun _ : Fin N => μ) i).map_eq] exact hgbound) have hmgCoord (i : Fin N) : ∀ᵐ x ∂ν, m (F (x i)) = g (F (x i)) := by exact ae_of_ae_map (μ := ν) (f := fun x : Fin N → ℝ × ℝ => x i) (p := fun p => m (F p) = g (F p)) (measurable_pi_apply i).aemeasurable (by rw [(measurePreserving_eval (fun _ : Fin N => μ) i).map_eq] exact hmg) have htagInt (i j : Fin N) (b : ℝ) : Integrable (fun x : Fin N → ℝ × ℝ => if (sort (fun k => (x k).1)).symm i = j then b * (x i).2 else 0) ν := by let C : Set (Fin N → ℝ × ℝ) := {x | (((Finset.univ : Finset (Fin N)).erase i).filter (fun k => F (x k) < F (x i))).card = j.val} have hL : Integrable (fun x : Fin N → ℝ × ℝ => if x ∈ C then b * (x i).2 else 0) ν := by apply Integrable.of_bound ((measurable_const.mul (measurable_snd.comp (measurable_pi_apply i))).ite (hC i j) measurable_const).aestronglyMeasurable |b| filter_upwards [hmarkBound i] with x hx change ‖(if x ∈ C then b * (x i).2 else 0 : ℝ)‖ ≤ |b| by_cases hc : x ∈ C · simpa [hc, Real.norm_eq_abs, abs_mul] using (mul_le_mul_of_nonneg_left hx (abs_nonneg b)) · simp [hc] apply hL.congr filter_upwards [hrank i j] with x hx simp only [C, Set.mem_ofPred_eq, if_congr hx rfl rfl] have hmeanInt (i j : Fin N) (b : ℝ) : Integrable (fun x : Fin N → ℝ × ℝ => if (sort (fun k => (x k).1)).symm i = j then b * m (F (x i)) else 0) ν := by let C : Set (Fin N → ℝ × ℝ) := {x | (((Finset.univ : Finset (Fin N)).erase i).filter (fun k => F (x k) < F (x i))).card = j.val} have hL : Integrable (fun x : Fin N → ℝ × ℝ => if x ∈ C then b * g (F (x i)) else 0) ν := by apply Integrable.of_bound ((measurable_const.mul (hg.comp (hF.comp (measurable_pi_apply i)))).ite (hC i j) measurable_const).aestronglyMeasurable |b| filter_upwards [hgBound i] with x hx change ‖(if x ∈ C then b * g (F (x i)) else 0 : ℝ)‖ ≤ |b| by_cases hc : x ∈ C · simpa [hc, Real.norm_eq_abs, abs_mul] using (mul_le_mul_of_nonneg_left hx (abs_nonneg b)) · simp [hc] apply hL.congr filter_upwards [hrank i j, hmgCoord i] with x hx hm' simp only [C, Set.mem_ofPred_eq, if_congr hx rfl rfl, hm'] have hpoint (x : Fin N → ℝ × ℝ) (z : Fin N → ℝ) : (∑ j : Fin N, a j * z ((sort (fun k => (x k).1)) j)) = ∑ i : Fin N, ∑ j : Fin N, if (sort (fun k => (x k).1)).symm i = j then a j * z i else 0 := by let σ := sort (fun k => (x k).1) have h := Equiv.sum_comp σ (fun i : Fin N => ∑ j : Fin N, if σ.symm i = j then a j * z i else 0) simpa only [σ, Equiv.symm_apply_apply, Finset.sum_ite_eq, Finset.mem_univ, if_true] using h have hterm (i j : Fin N) : (∫ x, (if (sort (fun k => (x k).1)).symm i = j then a j * (x i).2 else 0) ∂ν) = ∫ x, (if (sort (fun k => (x k).1)).symm i = j then a j * m (F (x i)) else 0) ∂ν := by calc _ = a j * ∫ x, (if (sort (fun k => (x k).1)).symm i = j then (x i).2 else 0) ∂ν := by rw [← integral_const_mul] congr 1 funext x split_ifs <;> simp [*] _ = a j * ∫ x, (if (sort (fun k => (x k).1)).symm i = j then m (F (x i)) else 0) ∂ν := by exact congrArg (a j * ·) (integral_tagged_rank_mark_eq_conditionalMean μ hcont hmark i j m hm) _ = _ := by rw [← integral_const_mul] congr 1 funext x split_ifs <;> simp [*] calc (∫ x, rankConcomitant a x ∂ν) = ∫ x, ∑ i : Fin N, ∑ j : Fin N, (if (sort (fun k => (x k).1)).symm i = j then a j * (x i).2 else 0) ∂ν := by apply integral_congr_ae exact Filter.Eventually.of_forall (fun x => by simpa only [rankConcomitant] using hpoint x (fun i => (x i).2)) _ = ∑ i : Fin N, ∑ j : Fin N, ∫ x, (if (sort (fun k => (x k).1)).symm i = j then a j * (x i).2 else 0) ∂ν := by rw [integral_finsetSum (s := Finset.univ) (fun i _ => integrable_finsetSum _ (fun j _ => htagInt i j (a j)))] congr 1 funext i rw [integral_finsetSum (s := Finset.univ) (fun j _ => htagInt i j (a j))] _ = ∑ i : Fin N, ∑ j : Fin N, ∫ x, (if (sort (fun k => (x k).1)).symm i = j then a j * m (F (x i)) else 0) ∂ν := by apply Finset.sum_congr rfl intro i _ apply Finset.sum_congr rfl intro j _ exact hterm i j _ = ∫ x, ∑ i : Fin N, ∑ j : Fin N, (if (sort (fun k => (x k).1)).symm i = j then a j * m (F (x i)) else 0) ∂ν := by rw [integral_finsetSum (s := Finset.univ) (fun i _ => integrable_finsetSum _ (fun j _ => hmeanInt i j (a j)))] congr 1 funext i rw [integral_finsetSum (s := Finset.univ) (fun j _ => hmeanInt i j (a j))] _ = _ := by apply integral_congr_ae exact Filter.Eventually.of_forall (fun x => by simpa only [F] using (hpoint x (fun i => m (F (x i)))).symm)
ConcomitantTagged 1 core · 0 supporting This module derives the conditional-mean identity for one tagged observation in a continuous rank-weighted marked sample. ★ integral_tagged_rank_mark_eq_conditionalMean
Tagged rank concomitant expectations
This module derives the conditional-mean identity for one tagged observation in a continuous rank-weighted marked sample.
For a bounded marked iid law, a continuous coordinate CDF, a tagged coordinate and rank, and a conditional mean function and version, one tagged mark restricted to one rank has the same expectation after replacing the mark by its conditional mean.
Formal statement
Proof (Lean source)
OrderStatisticMoments 1 core · 5 supporting Exact first and second moments of one coordinate of a sorted finite iid unit-uniform tuple. ★ simplex_coordinate_cross_moment
Uniform order-statistic moments
Exact first and second moments of one coordinate of a sorted finite iid unit-uniform tuple. These refine the existing spacing moment API.
Proof route: the first j+1 spacings sum to the jth zero-based order
statistic. The existing uniform-spacing law and coordinate-square moment
reduce the two order-statistic moments to the first and mixed moments of
coordinates in the spacing simplex, recorded separately below.
For a simplex dimension, two coordinates that are distinct, their factorial-scaled product integral is 1/((n+1)(n+2)).
Formal statement
Proof (Lean source)
5 supporting declarations (lemmas, instances)
-
simplex_coordinate_first_momenttheorem — For a simplex dimension and coordinate, the factorial-scaled mean of that spacing coordinate is 1/(n+1).hypothesesn :ℕi :Fin nconclusion(n.factorial : ℝ) * (∫ z in spacingSimplex n, z i ∂volume) = (1 : ℝ) / (n + 1)Proof (Lean source)
theorem simplex_coordinate_first_moment (n : ℕ) (i : Fin n) : (n.factorial : ℝ) * (∫ z in spacingSimplex n, z i ∂volume) = (1 : ℝ) / (n + 1) := by -- Slice the simplex by one coordinate and use permutation symmetry for `i`. have hfirst_fubini (m : ℕ) : (∫ z in spacingSimplex (m + 1), (z (0 : Fin (m + 1))) ∂volume) = ∫ t in Icc (0 : ℝ) 1, t * (volume (scaledSpacingSimplex m (1 - t))).toReal := by let e : (ℝ × (Fin m → ℝ)) ≃ᵐ (Fin (m + 1) → ℝ) := (piFinSuccAbove (fun _ => ℝ) 0).symm let S : Set (ℝ × (Fin m → ℝ)) := e ⁻¹' spacingSimplex (m + 1) have hem : MeasurePreserving e := (volume_preserving_piFinSuccAbove (fun _ : Fin (m + 1) => ℝ) 0).symm _ have hsimplex : MeasurableSet (spacingSimplex (m + 1)) := by have hclosed : IsClosed (spacingSimplex (m + 1)) := by change IsClosed {z : Fin (m + 1) → ℝ | (∀ i, 0 ≤ z i) ∧ (∑ i, z i) ≤ 1} apply IsClosed.inter · have hp : IsClosed (⋂ i : Fin (m + 1), (fun z : Fin (m + 1) → ℝ => z i) ⁻¹' Ici (0 : ℝ)) := isClosed_iInter (fun i => isClosed_Ici.preimage (continuous_apply i)) have heq : {z : Fin (m + 1) → ℝ | ∀ i, 0 ≤ z i} = ⋂ i : Fin (m + 1), (fun z : Fin (m + 1) → ℝ => z i) ⁻¹' Ici 0 := by ext z simp change IsClosed {z : Fin (m + 1) → ℝ | ∀ i, 0 ≤ z i} rw [heq] exact hp · exact isClosed_Iic.preimage (continuous_finsetSum _ (fun i _ => continuous_apply i)) exact hclosed.measurableSet have hS : MeasurableSet S := hsimplex.preimage e.measurable have hfinite : volume (spacingSimplex (m + 1)) ≠ ⊤ := by change volume (scaledSpacingSimplex (m + 1) 1) ≠ ⊤ rw [scaledSpacingSimplex_volume (m + 1) 1 (by norm_num)] simp have hInt : IntegrableOn (fun z : Fin (m + 1) → ℝ => z 0) (spacingSimplex (m + 1)) volume := by apply Measure.integrableOn_of_bounded hfinite ((measurable_pi_apply 0).aestronglyMeasurable) (M := 1) apply ae_restrict_of_forall_mem hsimplex intro z hz have h0 : 0 ≤ z 0 := hz.1 0 have hle : z 0 ≤ 1 := by calc z 0 ≤ ∑ i, z i := Finset.single_le_sum (fun i _ => hz.1 i) (Finset.mem_univ 0) _ ≤ 1 := hz.2 rw [Real.norm_eq_abs, abs_of_nonneg h0] exact hle have hpreInt : IntegrableOn (fun p : ℝ × (Fin m → ℝ) => p.1) S ((volume : Measure ℝ).prod volume) := by rw [← Measure.volume_eq_prod] rw [← hem.integrableOn_comp_preimage e.measurableEmbedding] at hInt convert hInt using 1 funext p simp [e, MeasurableEquiv.piFinSuccAbove_symm_apply, Fin.consEquiv] have hprodInt : Integrable (S.indicator (fun p : ℝ × (Fin m → ℝ) => p.1)) ((volume : Measure ℝ).prod volume) := by exact hpreInt.integrable_indicator hS have hsection (t : ℝ) (ht : t ∈ Icc (0 : ℝ) 1) : {w : Fin m → ℝ | (t, w) ∈ S} = scaledSpacingSimplex m (1 - t) := by simpa [S, e, MeasurableEquiv.piFinSuccAbove_symm_apply, Fin.insertNth_zero, Fin.consEquiv] using simplex_tail_section m t ht have hsubset (p : ℝ × (Fin m → ℝ)) (hp : p ∈ S) : p.1 ∈ Icc (0 : ℝ) 1 := by have hp' : cons p.1 p.2 ∈ spacingSimplex (m + 1) := by simpa [S, e, MeasurableEquiv.piFinSuccAbove_symm_apply, Fin.insertNth_zero, Fin.consEquiv] using hp have h0 : 0 ≤ p.1 := hp'.1 0 have hle : p.1 ≤ 1 := by calc p.1 ≤ ∑ i, (cons p.1 p.2) i := by simpa using (Finset.single_le_sum (fun i _ => hp'.1 i) (Finset.mem_univ (0 : Fin (m + 1)))) _ ≤ 1 := hp'.2 exact ⟨h0, hle⟩ have hfiber (t : ℝ) : (∫ w : Fin m → ℝ, S.indicator (fun p : ℝ × (Fin m → ℝ) => p.1) (t, w) ∂volume) = if ht : t ∈ Icc (0 : ℝ) 1 then t * (volume (scaledSpacingSimplex m (1 - t))).toReal else 0 := by split_ifs with ht · have hs : MeasurableSet {w : Fin m → ℝ | (t, w) ∈ S} := hS.preimage measurable_prodMk_left calc _ = ∫ w in {w : Fin m → ℝ | (t, w) ∈ S}, t ∂volume := by rw [← integral_indicator hs] congr 1 _ = t * (volume (scaledSpacingSimplex m (1 - t))).toReal := by rw [setIntegral_const, hsection t ht] simp [measureReal_def, smul_eq_mul, mul_comm] · have hzero : ∀ w : Fin m → ℝ, (t, w) ∉ S := by intro w hw exact ht (hsubset (t, w) hw) simp [indicator, hzero] calc (∫ z in spacingSimplex (m + 1), z 0 ∂volume) = ∫ p in S, p.1 ∂volume := by rw [← hem.map_eq, setIntegral_map_equiv] rfl _ = ∫ p : ℝ × (Fin m → ℝ), S.indicator (fun p : ℝ × (Fin m → ℝ) => p.1) p ∂volume := by rw [integral_indicator hS] _ = ∫ t : ℝ, ∫ w : Fin m → ℝ, S.indicator (fun p : ℝ × (Fin m → ℝ) => p.1) (t, w) ∂volume := by rw [Measure.volume_eq_prod] exact integral_prod _ hprodInt _ = ∫ t in Icc (0 : ℝ) 1, t * (volume (scaledSpacingSimplex m (1 - t))).toReal := by simp_rw [hfiber] rw [← integral_indicator measurableSet_Icc] congr 1 funext t simp [indicator, dite_eq_ite] have hfirst_slice (m : ℕ) : (∫ z in spacingSimplex (m + 1), (z (0 : Fin (m + 1))) ∂volume) = ∫ t in (0 : ℝ)..1, t * ((1 - t) ^ m / (m.factorial : ℝ)) := by rw [hfirst_fubini, intervalIntegral.integral_of_le (by norm_num : (0 : ℝ) ≤ 1), ← integral_Icc_eq_integral_Ioc] apply setIntegral_congr_fun measurableSet_Icc intro t ht have hr : 0 ≤ 1 - t := sub_nonneg.mpr ht.2 change t * (volume (scaledSpacingSimplex m (1 - t))).toReal = t * ((1 - t) ^ m / (m.factorial : ℝ)) rw [scaledSpacingSimplex_volume m (1 - t) hr] rw [ENNReal.toReal_ofReal (div_nonneg (pow_nonneg hr m) (by positivity))] have hbeta_first (m : ℕ) : (∫ t in (0 : ℝ)..1, t * (1 - t) ^ m) = (m.factorial : ℝ) / ((m + 2).factorial : ℝ) := by have hbeta : (∫ t in (0 : ℝ)..1, ((t * (1 - t) ^ m : ℝ) : ℂ)) = Complex.betaIntegral 2 (m + 1) := by rw [Complex.betaIntegral] apply intervalIntegral.integral_congr intro t ht have ht0 : 0 ≤ t := by simpa using ht.1 have ht1 : t ≤ 1 := by simpa using ht.2 dsimp simp only [Complex.ofReal_mul, Complex.ofReal_pow, Complex.ofReal_sub, Complex.ofReal_one] norm_num have heval := Complex.betaIntegral_eq_Gamma_mul_div 2 (m + 1) (by norm_num) (by simp; positivity) rw [← hbeta] at heval have hg3 : Complex.Gamma 2 = 1 := by convert Complex.Gamma_nat_eq_factorial 1 using 1 <;> norm_num have hgn : Complex.Gamma (m + 1) = (m.factorial : ℂ) := by simpa using Complex.Gamma_nat_eq_factorial m have hgn3 : Complex.Gamma (2 + (m + 1)) = ((m + 2).factorial : ℂ) := by convert Complex.Gamma_nat_eq_factorial (m + 2) using 1 <;> push_cast <;> ring rw [hg3, hgn, hgn3] at heval rw [intervalIntegral.integral_ofReal] at heval exact Complex.ofReal_inj.mp (by simpa using heval) have hcoord_eq_first (m : ℕ) (k : Fin m) : (∫ z in spacingSimplex m, z k ∂volume) = ∫ z in spacingSimplex m, z (⟨0, by have := k.isLt; omega⟩ : Fin m) ∂volume := by classical let j : Fin m := ⟨0, by have := k.isLt; omega⟩ let σ : Perm (Fin m) := Equiv.swap k j let e : (Fin m → ℝ) ≃ᵐ (Fin m → ℝ) := MeasurableEquiv.piCongrLeft (fun _ : Fin m => ℝ) σ.symm have he : MeasurePreserving e volume volume := volume_measurePreserving_piCongrLeft (fun _ : Fin m => ℝ) σ.symm have hfun (z : Fin m → ℝ) : e z = z ∘ σ := by funext k simp [e, MeasurableEquiv.coe_piCongrLeft, Equiv.piCongrLeft_apply] have hpre : e ⁻¹' spacingSimplex m = spacingSimplex m := by ext z simp only [Set.mem_preimage, spacingSimplex, Set.mem_ofPred_eq] rw [hfun] have hsum : (∑ k, z (σ k)) = ∑ k, z k := Equiv.sum_comp σ z constructor · rintro ⟨hp, hs⟩ exact ⟨fun k => by simpa using hp (σ.symm k), by simpa [hsum] using hs⟩ · rintro ⟨hp, hs⟩ exact ⟨fun k => hp (σ k), by simpa [hsum] using hs⟩ have hmp : MeasurePreserving e (volume.restrict (spacingSimplex m)) (volume.restrict (spacingSimplex m)) := by refine ⟨e.measurable, ?_⟩ calc (volume.restrict (spacingSimplex m)).map e = (volume.restrict (e ⁻¹' spacingSimplex m)).map e := by rw [hpre] _ = (volume.map e).restrict (spacingSimplex m) := (e.restrict_map volume (spacingSimplex m)).symm _ = volume.restrict (spacingSimplex m) := by rw [he.map_eq] have hint := hmp.integral_comp' (fun z : Fin m → ℝ => z j) simp only [hfun] at hint have hswap : σ j = k := Equiv.swap_apply_right k j simpa [j, hswap] using hint cases n with | zero => exact elim0 i | succ m => rw [hcoord_eq_first] change (m + 1).factorial * (∫ z in spacingSimplex (m + 1), z (0 : Fin (m + 1)) ∂volume) = _ rw [hfirst_slice] have hfactorial : (m + 1).factorial = (m + 1) * m.factorial := Nat.factorial_succ m simp_rw [← mul_div_assoc] rw [intervalIntegral.integral_div] rw [hbeta_first] norm_num [hfactorial, Nat.factorial_succ] have hm : (m.factorial : ℝ) ≠ 0 := by positivity field_simp -
scaled_simplex_coordinate_first_momenttheorem — For a simplex dimension, nonnegative scale, and coordinate, the factorial-scaled coordinate integral over the scaled simplex is r^(n+1)/(n+1).hypothesesconclusion(n.factorial : ℝ) * (∫ z in scaledSpacingSimplex n r, z i ∂volume) = r ^ (n + 1) / (n + 1)Proof (Lean source)
theorem scaled_simplex_coordinate_first_moment (n : ℕ) (r : ℝ) (hr : 0 ≤ r) (i : Fin n) : (n.factorial : ℝ) * (∫ z in scaledSpacingSimplex n r, z i ∂volume) = r ^ (n + 1) / (n + 1) := by classical have hn : n ≠ 0 := by have := i.isLt; omega by_cases hr0 : r = 0 · subst r have hzero : volume (scaledSpacingSimplex n 0) = 0 := by rw [scaledSpacingSimplex_volume n 0 (le_refl 0)] simp [hn] simp [hzero] · have hrpos : 0 < r := lt_of_le_of_ne hr (Ne.symm hr0) have hscale : r • spacingSimplex n = scaledSpacingSimplex n r := by ext z simp only [Set.mem_smul_set, spacingSimplex, scaledSpacingSimplex, Set.mem_ofPred_eq] constructor · rintro ⟨y, ⟨hp, hs⟩, rfl⟩ constructor · intro j simpa [Pi.smul_apply, smul_eq_mul] using mul_nonneg hr (hp j) · simpa [Pi.smul_apply, smul_eq_mul, ← Finset.mul_sum] using (mul_le_mul_of_nonneg_left hs hr) · rintro ⟨hp, hs⟩ refine ⟨r⁻¹ • z, ?_, ?_⟩ · constructor · intro j exact smul_nonneg (inv_nonneg.mpr hr) (hp j) · have hs' : (∑ j, (r⁻¹ • z) j) = r⁻¹ * ∑ j, z j := by simp [Pi.smul_apply, smul_eq_mul, Finset.mul_sum] rw [hs'] calc r⁻¹ * ∑ j, z j ≤ r⁻¹ * r := mul_le_mul_of_nonneg_left hs (inv_nonneg.mpr hr) _ = 1 := inv_mul_cancel₀ hr0 · simp [smul_smul, hr0] have hchange := Measure.setIntegral_comp_smul (μ := (volume : Measure (Fin n → ℝ))) (f := fun z : Fin n → ℝ => z i) (s := spacingSimplex n) hr0 rw [hscale] at hchange simp only [Pi.smul_apply, smul_eq_mul, Module.finrank_pi, Fintype.card_fin] at hchange rw [integral_const_mul] at hchange simp only [abs_of_nonneg (inv_nonneg.mpr (pow_nonneg hr n))] at hchange have hmean := simplex_coordinate_first_moment n i calc (n.factorial : ℝ) * (∫ z in scaledSpacingSimplex n r, z i ∂volume) = r ^ (n + 1) * ((n.factorial : ℝ) * (∫ z in spacingSimplex n, z i ∂volume)) := by have hpow : r ^ n ≠ 0 := pow_ne_zero n hr0 field_simp at hchange ⊢ rw [pow_succ] nlinarith [hchange] _ = r ^ (n + 1) / (n + 1) := by rw [hmean]; ring -
simplex_first_second_cross_fubinitheorem — For a remaining simplex dimension, the first two coordinate product integral is the first-coordinate slice weighted by the scaled tail's coordinate integral.hypothesesn :ℕconclusion= ∫ t in Icc (0 : ℝ) 1, t * (∫ w in scaledSpacingSimplex (n + 1) (1 - t), w (0 : Fin (n + 1)) ∂volume) ∂volumeProof (Lean source)
theorem simplex_first_second_cross_fubini (n : ℕ) : (∫ z in spacingSimplex (n + 2), z (0 : Fin (n + 2)) * z (1 : Fin (n + 2)) ∂volume) = ∫ t in Icc (0 : ℝ) 1, t * (∫ w in scaledSpacingSimplex (n + 1) (1 - t), w (0 : Fin (n + 1)) ∂volume) ∂volume := by let m := n + 1 let e : (ℝ × (Fin m → ℝ)) ≃ᵐ (Fin (m + 1) → ℝ) := (piFinSuccAbove (fun _ => ℝ) 0).symm let S : Set (ℝ × (Fin m → ℝ)) := e ⁻¹' spacingSimplex (m + 1) have hem : MeasurePreserving e := (volume_preserving_piFinSuccAbove (fun _ : Fin (m + 1) => ℝ) 0).symm _ have hsimplex : MeasurableSet (spacingSimplex (m + 1)) := by have hclosed : IsClosed (spacingSimplex (m + 1)) := by change IsClosed {z : Fin (m + 1) → ℝ | (∀ i, 0 ≤ z i) ∧ (∑ i, z i) ≤ 1} apply IsClosed.inter · have hp : IsClosed (⋂ i : Fin (m + 1), (fun z : Fin (m + 1) → ℝ => z i) ⁻¹' Ici (0 : ℝ)) := isClosed_iInter (fun i => isClosed_Ici.preimage (continuous_apply i)) have heq : {z : Fin (m + 1) → ℝ | ∀ i, 0 ≤ z i} = ⋂ i : Fin (m + 1), (fun z : Fin (m + 1) → ℝ => z i) ⁻¹' Ici 0 := by ext z simp change IsClosed {z : Fin (m + 1) → ℝ | ∀ i, 0 ≤ z i} rw [heq] exact hp · exact isClosed_Iic.preimage (continuous_finsetSum _ (fun i _ => continuous_apply i)) exact hclosed.measurableSet have hS : MeasurableSet S := hsimplex.preimage e.measurable have hfinite : volume (spacingSimplex (m + 1)) ≠ ⊤ := by change volume (scaledSpacingSimplex (m + 1) 1) ≠ ⊤ rw [scaledSpacingSimplex_volume (m + 1) 1 (by norm_num)] simp have hInt : IntegrableOn (fun z : Fin (m + 1) → ℝ => z 0 * z 1) (spacingSimplex (m + 1)) volume := by apply Measure.integrableOn_of_bounded hfinite (((measurable_pi_apply 0).mul (measurable_pi_apply 1)).aestronglyMeasurable) (M := 1) apply ae_restrict_of_forall_mem hsimplex intro z hz have hcoord (j : Fin (m + 1)) : 0 ≤ z j ∧ z j ≤ 1 := by refine ⟨hz.1 j, ?_⟩ calc z j ≤ ∑ k, z k := Finset.single_le_sum (fun k _ => hz.1 k) (Finset.mem_univ j) _ ≤ 1 := hz.2 change ‖z 0 * z 1‖ ≤ 1 rw [Real.norm_eq_abs, abs_of_nonneg (mul_nonneg (hcoord 0).1 (hcoord 1).1)] calc z 0 * z 1 ≤ 1 * z 1 := mul_le_mul_of_nonneg_right (hcoord 0).2 (hcoord 1).1 _ ≤ 1 := by simpa using (hcoord 1).2 have hpreInt : IntegrableOn (fun p : ℝ × (Fin m → ℝ) => p.1 * p.2 0) S ((volume : Measure ℝ).prod volume) := by rw [← Measure.volume_eq_prod] rw [← hem.integrableOn_comp_preimage e.measurableEmbedding] at hInt convert hInt using 1 funext p simp [e, MeasurableEquiv.piFinSuccAbove_symm_apply, Fin.consEquiv] have hprodInt : Integrable (S.indicator (fun p : ℝ × (Fin m → ℝ) => p.1 * p.2 0)) ((volume : Measure ℝ).prod volume) := hpreInt.integrable_indicator hS have hsection (t : ℝ) (ht : t ∈ Icc (0 : ℝ) 1) : {w : Fin m → ℝ | (t, w) ∈ S} = scaledSpacingSimplex m (1 - t) := by simpa [S, e, MeasurableEquiv.piFinSuccAbove_symm_apply, Fin.insertNth_zero, Fin.consEquiv] using simplex_tail_section m t ht have hsubset (p : ℝ × (Fin m → ℝ)) (hp : p ∈ S) : p.1 ∈ Icc (0 : ℝ) 1 := by have hp' : cons p.1 p.2 ∈ spacingSimplex (m + 1) := by simpa [S, e, MeasurableEquiv.piFinSuccAbove_symm_apply, Fin.insertNth_zero, Fin.consEquiv] using hp have h0 : 0 ≤ p.1 := hp'.1 0 have hle : p.1 ≤ 1 := by calc p.1 ≤ ∑ i, (cons p.1 p.2) i := by simpa using (Finset.single_le_sum (fun i _ => hp'.1 i) (Finset.mem_univ (0 : Fin (m + 1)))) _ ≤ 1 := hp'.2 exact ⟨h0, hle⟩ have hfiber (t : ℝ) : (∫ w : Fin m → ℝ, S.indicator (fun p : ℝ × (Fin m → ℝ) => p.1 * p.2 0) (t, w) ∂volume) = if ht : t ∈ Icc (0 : ℝ) 1 then t * (∫ w in scaledSpacingSimplex m (1 - t), w 0 ∂volume) else 0 := by split_ifs with ht · have hs : MeasurableSet {w : Fin m → ℝ | (t, w) ∈ S} := hS.preimage measurable_prodMk_left calc _ = ∫ w in {w : Fin m → ℝ | (t, w) ∈ S}, t * w 0 ∂volume := by rw [← integral_indicator hs] congr 1 _ = t * (∫ w in scaledSpacingSimplex m (1 - t), w 0 ∂volume) := by rw [hsection t ht, integral_const_mul] · have hzero : ∀ w : Fin m → ℝ, (t, w) ∉ S := by intro w hw exact ht (hsubset (t, w) hw) simp [indicator, hzero] change (∫ z in spacingSimplex (m + 1), z 0 * z 1 ∂volume) = _ calc (∫ z in spacingSimplex (m + 1), z 0 * z 1 ∂volume) = ∫ p in S, p.1 * p.2 0 ∂volume := by rw [← hem.map_eq, setIntegral_map_equiv] rfl _ = ∫ p : ℝ × (Fin m → ℝ), S.indicator (fun p : ℝ × (Fin m → ℝ) => p.1 * p.2 0) p ∂volume := by rw [integral_indicator hS] _ = ∫ t : ℝ, ∫ w : Fin m → ℝ, S.indicator (fun p : ℝ × (Fin m → ℝ) => p.1 * p.2 0) (t, w) ∂volume := by rw [Measure.volume_eq_prod] exact integral_prod _ hprodInt _ = ∫ t in Icc (0 : ℝ) 1, t * (∫ w in scaledSpacingSimplex m (1 - t), w 0 ∂volume) ∂volume := by simp_rw [hfiber] rw [← integral_indicator measurableSet_Icc] congr 1 funext t simp [indicator, dite_eq_ite] -
unit_beta_linear_integraltheorem — For a natural exponent, the first-moment beta integral over the unit interval equals the factorial ratio n!/(n+2)!.hypothesesn :ℕconclusion(∫ t in Icc (0 : ℝ) 1, t * (1 - t) ^ n ∂volume)= (n.factorial : ℝ) / ((n + 2).factorial : ℝ)Proof (Lean source)
theorem unit_beta_linear_integral (n : ℕ) : (∫ t in Icc (0 : ℝ) 1, t * (1 - t) ^ n ∂volume) = (n.factorial : ℝ) / ((n + 2).factorial : ℝ) := by have hbeta : (∫ t in (0 : ℝ)..1, t * (1 - t) ^ n) = (n.factorial : ℝ) / ((n + 2).factorial : ℝ) := by have hbeta_complex : (∫ t in (0 : ℝ)..1, ((t * (1 - t) ^ n : ℝ) : ℂ)) = Complex.betaIntegral 2 (n + 1) := by rw [Complex.betaIntegral] apply intervalIntegral.integral_congr intro t ht have ht0 : 0 ≤ t := by simpa using ht.1 have ht1 : t ≤ 1 := by simpa using ht.2 dsimp simp only [Complex.ofReal_mul, Complex.ofReal_pow, Complex.ofReal_sub, Complex.ofReal_one] norm_num have heval := Complex.betaIntegral_eq_Gamma_mul_div 2 (n + 1) (by norm_num) (by simp; positivity) rw [← hbeta_complex] at heval have hg3 : Complex.Gamma 2 = 1 := by convert Complex.Gamma_nat_eq_factorial 1 using 1 <;> norm_num have hgn : Complex.Gamma (n + 1) = (n.factorial : ℂ) := by simpa using Complex.Gamma_nat_eq_factorial n have hgn3 : Complex.Gamma (2 + (n + 1)) = ((n + 2).factorial : ℂ) := by convert Complex.Gamma_nat_eq_factorial (n + 2) using 1 <;> push_cast <;> ring rw [hg3, hgn, hgn3] at heval rw [intervalIntegral.integral_ofReal] at heval exact Complex.ofReal_inj.mp (by simpa using heval) rw [integral_Icc_eq_integral_Ioc, ← intervalIntegral.integral_of_le (by norm_num : (0 : ℝ) ≤ 1)] exact hbeta -
simplex_cross_coordinate_eq_first_twotheorem — For distinct coordinates in a spacing simplex, their product integral equals the product integral of coordinates zero and one.hypothesesconclusion(∫ z in spacingSimplex (n + 2), z i * z j ∂volume)Proof (Lean source)
theorem simplex_cross_coordinate_eq_first_two (n : ℕ) (i j : Fin (n + 2)) (hij : i ≠ j) : (∫ z in spacingSimplex (n + 2), z i * z j ∂volume) = ∫ z in spacingSimplex (n + 2), z (0 : Fin (n + 2)) * z (1 : Fin (n + 2)) ∂volume := by classical let τ : Perm (Fin (n + 2)) := swap 0 i let σ : Perm (Fin (n + 2)) := τ.trans (swap (τ 1) j) have hτ0 : τ 0 = i := Equiv.swap_apply_left 0 i have hτ1i : τ 1 ≠ i := by intro h have h' : (1 : Fin (n + 2)) = 0 := τ.injective (h.trans hτ0.symm) exact (by norm_num : (1 : Fin (n + 2)) ≠ 0) h' have hσ0 : σ 0 = i := by change (swap (τ 1) j) (τ 0) = i rw [hτ0] exact Equiv.swap_apply_of_ne_of_ne (Ne.symm hτ1i) hij have hσ1 : σ 1 = j := Equiv.swap_apply_left (τ 1) j let e : (Fin (n + 2) → ℝ) ≃ᵐ (Fin (n + 2) → ℝ) := MeasurableEquiv.piCongrLeft (fun _ : Fin (n + 2) => ℝ) σ.symm have he : MeasurePreserving e volume volume := volume_measurePreserving_piCongrLeft (fun _ : Fin (n + 2) => ℝ) σ.symm have hfun (z : Fin (n + 2) → ℝ) : e z = z ∘ σ := by funext k simp [e, MeasurableEquiv.coe_piCongrLeft, Equiv.piCongrLeft_apply] have hpre : e ⁻¹' spacingSimplex (n + 2) = spacingSimplex (n + 2) := by ext z simp only [Set.mem_preimage, spacingSimplex, Set.mem_ofPred_eq] rw [hfun] have hsum : (∑ k, z (σ k)) = ∑ k, z k := Equiv.sum_comp σ z constructor · rintro ⟨hp, hs⟩ exact ⟨fun k => by simpa using hp (σ.symm k), by simpa [hsum] using hs⟩ · rintro ⟨hp, hs⟩ exact ⟨fun k => hp (σ k), by simpa [hsum] using hs⟩ have hmp : MeasurePreserving e (volume.restrict (spacingSimplex (n + 2))) (volume.restrict (spacingSimplex (n + 2))) := by refine ⟨e.measurable, ?_⟩ calc (volume.restrict (spacingSimplex (n + 2))).map e = (volume.restrict (e ⁻¹' spacingSimplex (n + 2))).map e := by rw [hpre] _ = (volume.map e).restrict (spacingSimplex (n + 2)) := (e.restrict_map volume (spacingSimplex (n + 2))).symm _ = volume.restrict (spacingSimplex (n + 2)) := by rw [he.map_eq] have hint := hmp.integral_comp' (fun z : Fin (n + 2) → ℝ => z (0 : Fin (n + 2)) * z (1 : Fin (n + 2))) simp only [hfun] at hint simpa [hσ0, hσ1] using hint
PowerL1Core 1 core · 7 supporting The hinge-cell kernel is an adjacent order-statistic CDF. ★ bernsteinCell_power_eq_sub_curvature_hinge_integral
L1 approximation of the power density by finite Bernstein cells
The hinge-cell kernel is an adjacent order-statistic CDF. Combined with a curvature representation of a real power, this reduces the small-power L1 bound to the centered adjacent-mixture moment bound. The endpoint and large-power cases use unit-density identities.
For a positive sample size, power strictly above one, and evaluation point, the Bernstein kernel of the power cell masses equals the power itself minus the integral, over thresholds in the unit interval, of the curvature density times the Bernstein kernel of the hinge-cell increments at that threshold.
Formal statement
Proof (Lean source)
7 supporting declarations (lemmas, instances)
-
hingeCell_at_adjacenttheorem — At an adjacent threshold (k+δ)/N, multiplying a hinge-cell mass by N gives zero before cell k, 1-δ in cell k, and one after it.hypothesesconclusion(N : ℝ) * hingeCell N ((k + δ) / N) j= if (j : ℕ) < k then 0 else if (j : ℕ) = k then 1 - δ else 1Proof (Lean source)
theorem hingeCell_at_adjacent {N k : ℕ} (hN : 0 < N) (hk : k < N) {δ : ℝ} (hδ : δ ∈ Icc (0 : ℝ) 1) (j : Fin N) : (N : ℝ) * hingeCell N ((k + δ) / N) j = if (j : ℕ) < k then 0 else if (j : ℕ) = k then 1 - δ else 1 := by have hNr : (0 : ℝ) < N := by exact_mod_cast hN have hNne : (N : ℝ) ≠ 0 := ne_of_gt hNr rcases hδ with ⟨hδ0, hδ1⟩ rw [hingeCell_eq_piecewise hN] rcases lt_trichotomy (j : ℕ) k with hjk | hjk | hkj · have hjk' : ((j : ℕ) : ℝ) + 1 ≤ (k : ℝ) := by exact_mod_cast Nat.succ_le_of_lt hjk have hleft : ¬ (k + δ) / (N : ℝ) ≤ ((j : ℕ) : ℝ) / (N : ℝ) := by rw [div_le_div_iff_of_pos_right hNr] linarith simp only [if_pos hjk, if_neg hleft] split_ifs with hmid · have hmid' : (k : ℝ) + δ ≤ ((j : ℕ) : ℝ) + 1 := by exact (div_le_div_iff_of_pos_right hNr).mp hmid have heq : (k : ℝ) + δ = ((j : ℕ) : ℝ) + 1 := by linarith rw [← heq] ring · ring · subst k have hmid : ((j : ℕ) : ℝ) + δ ≤ ((j : ℕ) : ℝ) + 1 := by linarith have hmid' : (((j : ℕ) : ℝ) + δ) / (N : ℝ) ≤ (((j : ℕ) : ℝ) + 1) / (N : ℝ) := (div_le_div_iff_of_pos_right hNr).mpr hmid simp only [lt_self_iff_false, ↓reduceIte, if_pos hmid'] split_ifs with hleft · have hδeq : δ = 0 := by have := (div_le_div_iff_of_pos_right hNr).mp hleft linarith simp [hδeq, hNne] · field_simp ring · have hkj' : (k : ℝ) + 1 ≤ ((j : ℕ) : ℝ) := by exact_mod_cast Nat.succ_le_of_lt hkj have hleft : ((k : ℝ) + δ) / (N : ℝ) ≤ ((j : ℕ) : ℝ) / (N : ℝ) := (div_le_div_iff_of_pos_right hNr).mpr (by linarith) simp [not_lt.mpr (le_of_lt hkj), ne_of_gt hkj, hleft, hNne] -
bernsteinCell_hinge_eq_binomial_tailstheorem — The Bernstein kernel of an adjacent hinge is the convex combination of the two binomial upper tails with cutoffs k and k+1.hypothesesProof (Lean source)
theorem bernsteinCell_hinge_eq_binomial_tails {N k : ℕ} (hN : 0 < N) (hk : k < N) {δ : ℝ} (hδ : δ ∈ Icc (0 : ℝ) 1) (u : ℝ) : bernsteinCell N (hingeCell N ((k + δ) / N)) u = (1 - δ) * (∑ j ∈ Icc k (N - 1), (choose (N - 1) j : ℝ) * u ^ j * (1 - u) ^ (N - 1 - j)) + δ * (∑ j ∈ Icc (k + 1) (N - 1), (choose (N - 1) j : ℝ) * u ^ j * (1 - u) ^ (N - 1 - j)) := by let f : ℕ → ℝ := fun j => (choose (N - 1) j : ℝ) * u ^ j * (1 - u) ^ (N - 1 - j) have hsets (a : ℕ) : Icc a (N - 1) = (range N).filter (fun j => a ≤ j) := by ext j simp only [Finset.mem_Icc, mem_filter, Finset.mem_range] omega have htail (a : ℕ) : (∑ j ∈ range N, if a ≤ j then f j else 0) = ∑ j ∈ Icc a (N - 1), f j := by rw [hsets, Finset.sum_filter] have hcoeff (j : ℕ) : (if j < k then (0 : ℝ) else if j = k then 1 - δ else 1) = (if k ≤ j then 1 - δ else 0) + (if k + 1 ≤ j then δ else 0) := by rcases lt_trichotomy j k with h | h | h · simp [h, show ¬ k ≤ j by omega, show ¬ k + 1 ≤ j by omega] · subst j simp · have hkj : k + 1 ≤ j := succ_le_of_lt h simp [show ¬ j < k by omega, show j ≠ k by omega, hkj, le_of_lt h] calc bernsteinCell N (hingeCell N ((k + δ) / N)) u = ∑ j : Fin N, ((if (j : ℕ) < k then (0 : ℝ) else if (j : ℕ) = k then 1 - δ else 1) * f (j : ℕ)) := by unfold bernsteinCell rw [Finset.mul_sum] apply Finset.sum_congr rfl intro j hj rw [← hingeCell_at_adjacent hN hk hδ j] dsimp [f] ring _ = ∑ j ∈ range N, ((if j < k then (0 : ℝ) else if j = k then 1 - δ else 1) * f j) := by simpa only using (Fin.sum_univ_eq_sum_range (fun j : ℕ => (if j < k then (0 : ℝ) else if j = k then 1 - δ else 1) * f j) N) _ = ∑ j ∈ range N, ((if k ≤ j then 1 - δ else 0) * f j + (if k + 1 ≤ j then δ else 0) * f j) := by apply Finset.sum_congr rfl intro j hj rw [hcoeff j] ring _ = (1 - δ) * (∑ j ∈ Icc k (N - 1), f j) + δ * (∑ j ∈ Icc (k + 1) (N - 1), f j) := by calc _ = ∑ j ∈ range N, ((1 - δ) * (if k ≤ j then f j else 0) + δ * (if k + 1 ≤ j then f j else 0)) := by apply Finset.sum_congr rfl intro j hj simp only [ite_mul, mul_ite, zero_mul, mul_zero] _ = _ := by rw [Finset.sum_add_distrib, ← Finset.mul_sum, ← Finset.mul_sum, htail k, htail (k + 1)] _ = _ := rfl -
bernsteinCell_hinge_eq_adjacent_cdftheorem — For a positive sample size, adjacent cell, and interpolation fraction, at an interior point, the Bernstein density of the corresponding hinge increments is the CDF of the adjacent order-statistic mixture at each interior point of the unit interval.hypothesesconclusionbernsteinCell N (hingeCell N ((k + δ) / N)) uProof (Lean source)
theorem bernsteinCell_hinge_eq_adjacent_cdf {N k : ℕ} (hN : 0 < N) (hk : k < N) {δ : ℝ} (hδ : δ ∈ Icc (0 : ℝ) 1) {u : ℝ} (hu : u ∈ Ioo (0 : ℝ) 1) : bernsteinCell N (hingeCell N ((k + δ) / N)) u = ((adjacentOrderMix N k δ) (Iic u)).toReal := by -- A hinge increment is 0 below cell k, (1-δ)/N in cell k, and -- 1/N above it. The Bernstein binomial tail is the CDF of the -- kth order statistic of N-1 uniforms; mix the adjacent tails. -- At δ=1 and u=1 the deterministic upper endpoint creates a CDF jump, -- so this exact pointwise identity is stated on the open interval. let ν := iidSample uniform01 (N - 1) let μ₀ : Measure ℝ := ν.map (fun x => if h : k = 0 then (0 : ℝ) else if h' : k ≤ N - 1 then sortedSample (N - 1) x ⟨k - 1, by omega⟩ else 1) let μ₁ : Measure ℝ := ν.map (fun x => if h : k + 1 = N then (1 : ℝ) else if h' : k < N - 1 then sortedSample (N - 1) x ⟨k, h'⟩ else 1) haveI : IsProbabilityMeasure uniform01 := ⟨by simp [uniform01]⟩ have hν : IsProbabilityMeasure ν := by dsimp [ν, iidSample] infer_instance letI := hν haveI : IsFiniteMeasure μ₀ := by dsimp [μ₀] exact Measure.isFiniteMeasure_map ν _ haveI : IsFiniteMeasure μ₁ := by dsimp [μ₁] exact Measure.isFiniteMeasure_map ν _ haveI : IsFiniteMeasure ((ofReal (1 - δ)) • μ₀) := Measure.smul_finite μ₀ (by simp) haveI : IsFiniteMeasure ((ofReal δ) • μ₁) := Measure.smul_finite μ₁ (by simp) have hδ₀ : 0 ≤ δ := hδ.1 have hδ₁ : 0 ≤ 1 - δ := by linarith [hδ.2] have hmix : ((adjacentOrderMix N k δ) (Iic u)).toReal = (1 - δ) * (μ₀ (Iic u)).toReal + δ * (μ₁ (Iic u)).toReal := by change (((ofReal (1 - δ)) • μ₀ + (ofReal δ) • μ₁) (Iic u)).toReal = _ rw [← Measure.real, measureReal_add_apply, measureReal_ennreal_smul_apply, measureReal_ennreal_smul_apply] simp [Measure.real, ENNReal.toReal_ofReal hδ₀, ENNReal.toReal_ofReal hδ₁] have hL : (μ₀ (Iic u)).toReal = ∑ j ∈ Icc k (N - 1), (choose (N - 1) j : ℝ) * u ^ j * (1 - u) ^ (N - 1 - j) := by by_cases hk₀ : k = 0 · subst k have hs : (∑ j ∈ Icc 0 (N - 1), (choose (N - 1) j : ℝ) * u ^ j * (1 - u) ^ (N - 1 - j)) = 1 := by have hI : Icc 0 (N - 1) = range ((N - 1) + 1) := by ext j simp only [Finset.mem_Icc, zero_le, true_and, Finset.mem_range] omega rw [hI] calc _ = ∑ j ∈ range (N - 1 + 1), u ^ j * (1 - u) ^ (N - 1 - j) * (choose (N - 1) j : ℝ) := by apply Finset.sum_congr rfl intro j hj ring _ = (u + (1 - u)) ^ (N - 1) := by rw [add_pow] _ = 1 := by simp simp [μ₀, Measure.map_const, hs, hu.1.le] · have hkn : k ≤ N - 1 := by omega have hr : k - 1 < N - 1 := by omega have hks : k - 1 + 1 = k := by omega simp only [μ₀, hk₀, hkn, dite_false, dite_true] rw [uniform_sorted_cdf_eq_binomial_tail ⟨k - 1, hr⟩ ⟨hu.1.le, hu.2.le⟩] have h1u : 0 ≤ 1 - u := by linarith [hu.2] rw [hks, ENNReal.toReal_ofReal (Finset.sum_nonneg (by intro j hj exact mul_nonneg (mul_nonneg (by positivity) (pow_nonneg hu.1.le _)) (pow_nonneg h1u _)))] have hU : (μ₁ (Iic u)).toReal = ∑ j ∈ Icc (k + 1) (N - 1), (choose (N - 1) j : ℝ) * u ^ j * (1 - u) ^ (N - 1 - j) := by by_cases htop : k + 1 = N · have hs : (∑ j ∈ Icc (k + 1) (N - 1), (choose (N - 1) j : ℝ) * u ^ j * (1 - u) ^ (N - 1 - j)) = 0 := by have : Icc (k + 1) (N - 1) = ∅ := by apply Finset.Icc_eq_empty_of_lt omega simp [this] have heq : μ₁ = ν.map (fun _ => (1 : ℝ)) := by simp [μ₁, htop] rw [heq, Measure.map_const] simp [hs, Set.mem_Iic, not_le.mpr hu.2] · have hkn : k < N - 1 := by omega have hks : k + 1 ≤ N - 1 := by omega simp only [μ₁, htop, hkn, dite_false, dite_true] rw [uniform_sorted_cdf_eq_binomial_tail ⟨k, hkn⟩ ⟨hu.1.le, hu.2.le⟩] have h1u : 0 ≤ 1 - u := by linarith [hu.2] rw [ENNReal.toReal_ofReal (Finset.sum_nonneg (by intro j hj exact mul_nonneg (mul_nonneg (by positivity) (pow_nonneg hu.1.le _)) (pow_nonneg h1u _)))] rw [bernsteinCell_hinge_eq_binomial_tails hN hk hδ u, hmix, hL, hU] -
unit_threshold_eq_adjacenttheorem — Every threshold in the unit interval lies in an adjacent cell of a positive sample size, including the right endpoint by taking the last cell and interpolation fraction one.hypothesesconclusion∃ k : ℕ, ∃ δ : ℝ,conclusion 1k < Nconclusion 2δ ∈ Icc (0 : ℝ) 1conclusion 3t = (k + δ) / NProof (Lean source)
theorem unit_threshold_eq_adjacent {N : ℕ} (hN : 0 < N) {t : ℝ} (ht : t ∈ Icc (0 : ℝ) 1) : ∃ k : ℕ, ∃ δ : ℝ, k < N ∧ δ ∈ Icc (0 : ℝ) 1 ∧ t = (k + δ) / N := by have hNr : (0 : ℝ) < N := by exact_mod_cast hN have hNne : (N : ℝ) ≠ 0 := ne_of_gt hNr by_cases htop : t = 1 · refine ⟨N - 1, 1, by omega, by norm_num, ?_⟩ rw [htop] have hlast : ((N - 1 : ℕ) : ℝ) + 1 = N := by exact_mod_cast (by omega : N - 1 + 1 = N) rw [hlast] exact (div_self hNne).symm · have htlt : t < 1 := lt_of_le_of_ne ht.2 htop let k := Nat.floor ((N : ℝ) * t) let δ := (N : ℝ) * t - k have hNt0 : 0 ≤ (N : ℝ) * t := mul_nonneg hNr.le ht.1 have hklo : (k : ℝ) ≤ (N : ℝ) * t := Nat.floor_le hNt0 have hkhi : (N : ℝ) * t < (k : ℝ) + 1 := Nat.lt_floor_add_one _ have hkN : k < N := by have hkr : (k : ℝ) < N := lt_of_le_of_lt hklo (mul_lt_of_lt_one_right hNr htlt) exact_mod_cast hkr refine ⟨k, δ, hkN, ⟨by dsimp [δ]; linarith, by dsimp [δ]; linarith⟩, ?_⟩ dsimp [δ] field_simp ring -
bernsteinCell_hinge_indicator_L1theorem — For a unit-interval threshold, the Bernstein kernel of its hinge cells approximates the threshold step function in L1 with error at most sqrt (2*t/N) for a positive sample size.hypothesesconclusion(∫ u in Icc (0 : ℝ) 1, |bernsteinCell N (hingeCell N t) u - (if t ≤ u then (1 : ℝ) else 0)| ∂volume)≤ sqrt (2 * t / N)Proof (Lean source)
theorem bernsteinCell_hinge_indicator_L1 {N : ℕ} (hN : 0 < N) {t : ℝ} (ht : t ∈ Icc (0 : ℝ) 1) : (∫ u in Icc (0 : ℝ) 1, |bernsteinCell N (hingeCell N t) u - (if t ≤ u then (1 : ℝ) else 0)| ∂volume) ≤ sqrt (2 * t / N) := by obtain ⟨k, δ, hk, hδ, rfl⟩ := unit_threshold_eq_adjacent hN ht have hEq : (∫ u in Icc (0 : ℝ) 1, |bernsteinCell N (hingeCell N ((k + δ) / N)) u - (if (k + δ) / N ≤ u then (1 : ℝ) else 0)| ∂volume) = (∫ u in Icc (0 : ℝ) 1, |((adjacentOrderMix N k δ) (Iic u)).toReal - (if (k + δ) / N ≤ u then (1 : ℝ) else 0)| ∂volume) := by simp only [integral_Icc_eq_integral_Ioo] apply setIntegral_congr_fun measurableSet_Ioo intro u hu dsimp rw [bernsteinCell_hinge_eq_adjacent_cdf hN hk hδ hu] rw [hEq] exact _root_.Causalean.Stat.OrderStatistic.WeightedConcomitant.adjacentOrderMix_indicator_L1_le_sqrt_two_t_over_N hN hk hδ -
powerDensity_eq_sub_curvature_integraltheorem — For a power strictly greater than one and unit-interval point, the power density is a constant minus its integrated curvature thresholds.hypothesesconclusionpowerDensity s u= s- ∫ t in Icc (0 : ℝ) 1, powerCurvature s t * (if t ≤ u then (1 : ℝ) else 0) ∂volumeProof (Lean source)
theorem powerDensity_eq_sub_curvature_integral {s u : ℝ} (hs : 1 < s) (hu : u ∈ Icc (0 : ℝ) 1) : powerDensity s u = s - ∫ t in Icc (0 : ℝ) 1, powerCurvature s t * (if t ≤ u then (1 : ℝ) else 0) ∂volume := by have hind : (fun t : ℝ => powerCurvature s t * (if t ≤ u then (1 : ℝ) else 0)) = (Iic u).indicator (powerCurvature s) := by funext t by_cases ht : t ≤ u <;> simp [indicator, ht] have hset : Icc (0 : ℝ) 1 ∩ Iic u = Icc 0 u := by ext t simp only [Set.mem_inter_iff, Set.mem_Icc, Set.mem_Iic] constructor · rintro ⟨⟨ht0, _⟩, htu⟩ exact ⟨ht0, htu⟩ · rintro ⟨ht0, htu⟩ exact ⟨⟨ht0, htu.trans hu.2⟩, htu⟩ rw [hind, setIntegral_indicator measurableSet_Iic, hset, integral_powerCurvature_Icc hs hu] ring -
powerCell_eq_sub_curvature_hinge_integraltheorem — For a positive sample size and a real power above one, each power cell mass is its constant-density mass minus the curvature-weighted hinge cell.hypothesesconclusionpowerCell N s jProof (Lean source)
theorem powerCell_eq_sub_curvature_hinge_integral {N : ℕ} (hN : 0 < N) {s : ℝ} (hs : 1 < s) (j : Fin N) : powerCell N s j = s / N - ∫ t in Icc (0 : ℝ) 1, powerCurvature s t * hingeCell N t j ∂volume := by let a : ℝ := (j : ℝ) / N let b : ℝ := (((j : ℕ) + 1 : ℝ) / N) have hNr : (0 : ℝ) < N := by exact_mod_cast hN have hab : a ≤ b := by dsimp [a, b] apply div_le_div_of_nonneg_right _ hNr.le linarith have ha0 : 0 ≤ a := by dsimp [a]; positivity have hb1 : b ≤ 1 := by dsimp [b] apply (div_le_one hNr).2 exact_mod_cast j.isLt have hgeom (t : ℝ) : (∫ u in Ioc a b, if t ≤ u then (1 : ℝ) else 0 ∂volume) = hingeCell N t j := by have hstep : (∫ u in Ioc a b, if t ≤ u then (1 : ℝ) else 0 ∂volume) = (∫ u in Ioc a b, (Ioi t).indicator (fun _ => (1 : ℝ)) u ∂volume) := by apply integral_congr_ae filter_upwards [ae_restrict_of_ae (volume.ae_ne t)] with u hu by_cases htu : t < u · simp [indicator, htu, htu.le] · have : ¬ t ≤ u := by intro h rcases h.eq_or_lt with he | hl · exact hu he.symm · exact htu hl simp [indicator, htu, this] rw [hstep, setIntegral_indicator measurableSet_Ioi, Set.Ioc_inter_Ioi] simp only [setIntegral_const, smul_eq_mul, mul_one, Real.volume_real_Ioc] change max (b - max a t) 0 = max (b - t) 0 - max (a - t) 0 rcases le_total t a with h | h · rw [max_eq_left h] simp [max_eq_left (by linarith : 0 ≤ b - a), max_eq_left (by linarith : 0 ≤ b - t), max_eq_left (by linarith : 0 ≤ a - t)] · rcases le_total t b with h' | h' · rw [max_eq_right h] simp [max_eq_left (by linarith : 0 ≤ b - t), max_eq_right (by linarith : a - t ≤ 0)] · rw [max_eq_right h] simp [max_eq_right (by linarith : b - t ≤ 0), max_eq_right (by linarith : a - t ≤ 0)] have hr : IntervalIntegrable (fun x : ℝ => x ^ (s - 2)) volume 0 1 := intervalIntegral.intervalIntegrable_rpow' (by linarith) have hr' : IntervalIntegrable (fun t : ℝ => (1 - t) ^ (s - 2)) volume 0 1 := by convert (hr.comp_sub_left 1).symm using 1 <;> norm_num have hq : Integrable (powerCurvature s) (volume.restrict (Icc (0 : ℝ) 1)) := by apply (intervalIntegrable_iff_integrableOn_Icc_of_le (by norm_num : (0 : ℝ) ≤ 1)).mp change IntervalIntegrable (fun t : ℝ => s * (s - 1) * (1 - t) ^ (s - 2)) volume 0 1 exact hr'.const_mul (s * (s - 1)) let μ := volume.restrict (Ioc a b) let ν := volume.restrict (Icc (0 : ℝ) 1) have hqprod : Integrable (fun z : ℝ × ℝ => powerCurvature s z.2) (μ.prod ν) := by exact hq.comp_snd μ have hF : Integrable (fun z : ℝ × ℝ => powerCurvature s z.2 * if z.2 ≤ z.1 then (1 : ℝ) else 0) (μ.prod ν) := by apply hqprod.mul_bdd (c := 1) · exact ((measurable_const.ite (measurableSet_le measurable_snd measurable_fst) measurable_const).aestronglyMeasurable) · filter_upwards [] with z split_ifs <;> simp have hswap : (∫ u in Ioc a b, ∫ t in Icc (0 : ℝ) 1, powerCurvature s t * if t ≤ u then (1 : ℝ) else 0 ∂volume ∂volume) = (∫ t in Icc (0 : ℝ) 1, ∫ u in Ioc a b, powerCurvature s t * if t ≤ u then (1 : ℝ) else 0 ∂volume ∂volume) := by exact integral_integral_swap (μ := μ) (ν := ν) hF have hinner_int : Integrable (fun u : ℝ => ∫ t in Icc (0 : ℝ) 1, powerCurvature s t * if t ≤ u then (1 : ℝ) else 0 ∂volume) μ := hF.integral_prod_left have hcell : powerCell N s j = ∫ u in Ioc a b, powerDensity s u ∂volume := by rw [powerCell_eq_integral hN hs.le j, intervalIntegral.integral_of_le hab] rfl have hconst : (∫ u in Ioc a b, s ∂volume) = s / N := by rw [setIntegral_const, Real.volume_real_Ioc_of_le hab] simp only [smul_eq_mul] dsimp [a, b] field_simp ring calc powerCell N s j = ∫ u in Ioc a b, powerDensity s u ∂volume := hcell _ = ∫ u in Ioc a b, s - ∫ t in Icc (0 : ℝ) 1, powerCurvature s t * if t ≤ u then (1 : ℝ) else 0 ∂volume ∂volume := by apply integral_congr_ae filter_upwards [ae_restrict_mem measurableSet_Ioc] with u hu exact powerDensity_eq_sub_curvature_integral hs ⟨ha0.trans hu.1.le, hu.2.trans hb1⟩ _ = s / N - ∫ u in Ioc a b, ∫ t in Icc (0 : ℝ) 1, powerCurvature s t * if t ≤ u then (1 : ℝ) else 0 ∂volume ∂volume := by rw [integral_sub (integrable_const _) hinner_int, hconst] _ = s / N - ∫ t in Icc (0 : ℝ) 1, ∫ u in Ioc a b, powerCurvature s t * if t ≤ u then (1 : ℝ) else 0 ∂volume ∂volume := by rw [hswap] _ = s / N - ∫ t in Icc (0 : ℝ) 1, powerCurvature s t * hingeCell N t j ∂volume := by congr 1 apply integral_congr_ae filter_upwards [] with t rw [integral_const_mul, hgeom]
PowerL1Error 1 core · 6 supporting This module integrates the adjacent-order-statistic hinge error and proves the finite Bernstein L1 approximation for real power weights. ★ power_bernstein_L1
Curvature control of the Bernstein power approximation
This module integrates the adjacent-order-statistic hinge error and proves the finite Bernstein L1 approximation for real power weights.
For a positive sample size and real power at least one, the Bernstein power kernel has L1 error at most 2 sqrt(s/N).
Formal statement
Proof (Lean source)
6 supporting declarations (lemmas, instances)
-
power_curvature_hinge_error_integrabletheorem — For a power above one, the curvature times the absolute error of the Bernstein hinge approximation is integrable on the unit square. This is the Fubini prerequisite for the power-density bound.hypothesesN :ℕs :ℝhs :1 < sconclusionIntegrable (fun p : ℝ × ℝ => powerCurvature s p.1 * |bernsteinCell N (hingeCell N p.1) p.2 - (if p.1 ≤ p.2 then (1 : ℝ) else 0)|) ((volume.restrict (Icc (0 : ℝ) 1)).prod (volume.restrict (Icc (0 : ℝ) 1)))Proof (Lean source)
theorem power_curvature_hinge_error_integrable {N : ℕ} {s : ℝ} (hs : 1 < s) : Integrable (fun p : ℝ × ℝ => powerCurvature s p.1 * |bernsteinCell N (hingeCell N p.1) p.2 - (if p.1 ≤ p.2 then (1 : ℝ) else 0)|) ((volume.restrict (Icc (0 : ℝ) 1)).prod (volume.restrict (Icc (0 : ℝ) 1))) := by -- Bound the hinge kernel and the step by one; curvature is integrable -- even when 1 < s < 2 and it is singular at the right endpoint. let I : Set ℝ := Icc 0 1 let μ : Measure ℝ := volume.restrict I have hq : Integrable (powerCurvature s) μ := by apply (intervalIntegrable_iff_integrableOn_Icc_of_le (by norm_num : (0 : ℝ) ≤ 1)).mp have hr : IntervalIntegrable (fun x : ℝ => x ^ (s - 2)) volume 0 1 := intervalIntegral.intervalIntegrable_rpow' (by linarith) have hr' : IntervalIntegrable (fun t : ℝ => (1 - t) ^ (s - 2)) volume 0 1 := by convert (hr.comp_sub_left 1).symm using 1 <;> norm_num change IntervalIntegrable (fun t : ℝ => s * (s - 1) * (1 - t) ^ (s - 2)) volume 0 1 exact hr'.const_mul (s * (s - 1)) have hc : Continuous (fun p : ℝ × ℝ => bernsteinCell N (hingeCell N p.1) p.2) := by unfold bernsteinCell hingeCell fun_prop obtain ⟨C, hC⟩ := (isCompact_Icc.prod isCompact_Icc).exists_bound_of_continuousOn (hc.continuousOn : ContinuousOn (fun p : ℝ × ℝ => bernsteinCell N (hingeCell N p.1) p.2) (I ×ˢ I)) have he : AEStronglyMeasurable (fun p : ℝ × ℝ => |bernsteinCell N (hingeCell N p.1) p.2 - (if p.1 ≤ p.2 then (1 : ℝ) else 0)|) (μ.prod μ) := by apply Measurable.aestronglyMeasurable apply Measurable.abs apply Measurable.sub · exact hc.measurable · exact Measurable.ite (measurableSet_le measurable_fst measurable_snd) measurable_const measurable_const have hbound : ∀ᵐ p : ℝ × ℝ ∂μ.prod μ, ‖bernsteinCell N (hingeCell N p.1) p.2 - (if p.1 ≤ p.2 then (1 : ℝ) else 0)‖ ≤ C + 1 := by rw [Measure.prod_restrict] filter_upwards [ae_restrict_mem (measurableSet_Icc.prod measurableSet_Icc)] with p hp calc _ ≤ ‖bernsteinCell N (hingeCell N p.1) p.2‖ + ‖(if p.1 ≤ p.2 then (1 : ℝ) else 0)‖ := norm_sub_le _ _ _ ≤ C + 1 := by apply add_le_add (hC p hp) split_ifs <;> norm_num have hqprod : Integrable (fun p : ℝ × ℝ => powerCurvature s p.1) (μ.prod μ) := hq.comp_fst μ have hbound' : ∀ᵐ p : ℝ × ℝ ∂μ.prod μ, ‖|bernsteinCell N (hingeCell N p.1) p.2 - (if p.1 ≤ p.2 then (1 : ℝ) else 0)|‖ ≤ C + 1 := by simpa only [Real.norm_eq_abs, abs_abs] using hbound have hint := hqprod.mul_bdd he hbound' simpa only [μ, I] using hint -
power_curvature_hinge_error_integral_letheorem — The L1 norm of the integrated, curvature-weighted hinge error is at most the curvature-weighted integral of its pointwise L1 norms.hypothesesN :ℕs :ℝhs :1 < sconclusion(∫ u in Icc (0 : ℝ) 1, |∫ t in Icc (0 : ℝ) 1, powerCurvature s t * (bernsteinCell N (hingeCell N t) u - (if t ≤ u then (1 : ℝ) else 0)) ∂volume| ∂volume)≤ ∫ t in Icc (0 : ℝ) 1, powerCurvature s t * (∫ u in Icc (0 : ℝ) 1, |bernsteinCell N (hingeCell N t) u - (if t ≤ u then (1 : ℝ) else 0)| ∂volume) ∂volumeProof (Lean source)
theorem power_curvature_hinge_error_integral_le {N : ℕ} {s : ℝ} (hs : 1 < s) : (∫ u in Icc (0 : ℝ) 1, |∫ t in Icc (0 : ℝ) 1, powerCurvature s t * (bernsteinCell N (hingeCell N t) u - (if t ≤ u then (1 : ℝ) else 0)) ∂volume| ∂volume) ≤ ∫ t in Icc (0 : ℝ) 1, powerCurvature s t * (∫ u in Icc (0 : ℝ) 1, |bernsteinCell N (hingeCell N t) u - (if t ≤ u then (1 : ℝ) else 0)| ∂volume) ∂volume := by -- Apply abs_integral_le_integral_abs for each u and integral_prod_symm -- using power_curvature_hinge_error_integrable. let I : Set ℝ := Icc 0 1 let μ : Measure ℝ := volume.restrict I let F : ℝ × ℝ → ℝ := fun p => powerCurvature s p.1 * (bernsteinCell N (hingeCell N p.1) p.2 - (if p.1 ≤ p.2 then (1 : ℝ) else 0)) let G : ℝ × ℝ → ℝ := fun p => powerCurvature s p.1 * |bernsteinCell N (hingeCell N p.1) p.2 - (if p.1 ≤ p.2 then (1 : ℝ) else 0)| have hG : Integrable G (μ.prod μ) := power_curvature_hinge_error_integrable hs have hFmeas : AEStronglyMeasurable F (μ.prod μ) := by apply Measurable.aestronglyMeasurable dsimp [F, powerCurvature, bernsteinCell, hingeCell] apply mul · fun_prop · apply Measurable.sub · fun_prop · exact Measurable.ite (measurableSet_le measurable_fst measurable_snd) measurable_const measurable_const have hqnonneg : ∀ t ∈ I, 0 ≤ powerCurvature s t := by intro t ht unfold powerCurvature exact mul_nonneg (mul_nonneg (by linarith) (by linarith)) (Real.rpow_nonneg (by have := ht.2; dsimp [I] at ht; linarith) _) have hnorm : ∀ᵐ p : ℝ × ℝ ∂μ.prod μ, ‖F p‖ = G p := by rw [Measure.prod_restrict] filter_upwards [ae_restrict_mem (measurableSet_Icc.prod measurableSet_Icc)] with p hp dsimp [F, G] rw [abs_mul, abs_of_nonneg (hqnonneg p.1 hp.1)] have hF : Integrable F (μ.prod μ) := by apply (integrable_norm_iff hFmeas).1 exact hG.congr (by filter_upwards [hnorm] with p hp; exact hp.symm) have houterF : Integrable (fun u => ∫ t, F (t, u) ∂μ) μ := hF.swap.integral_prod_left have houterG : Integrable (fun u => ∫ t, G (t, u) ∂μ) μ := hG.swap.integral_prod_left have hpoint (u : ℝ) : |∫ t, F (t, u) ∂μ| ≤ ∫ t, G (t, u) ∂μ := by calc _ ≤ ∫ t, |F (t, u)| ∂μ := abs_integral_le_integral_abs _ = ∫ t, G (t, u) ∂μ := by apply integral_congr_ae filter_upwards [ae_restrict_mem measurableSet_Icc] with t ht dsimp [F, G] rw [abs_mul, abs_of_nonneg (hqnonneg t ht)] have hle : (∫ u, |∫ t, F (t, u) ∂μ| ∂μ) ≤ ∫ u, (∫ t, G (t, u) ∂μ) ∂μ := integral_mono houterF.abs houterG hpoint have hswap : (∫ u, (∫ t, G (t, u) ∂μ) ∂μ) = ∫ t, (∫ u, G (t, u) ∂μ) ∂μ := (integral_integral_swap hG).symm calc _ = ∫ u, |∫ t, F (t, u) ∂μ| ∂μ := rfl _ ≤ ∫ u, (∫ t, G (t, u) ∂μ) ∂μ := hle _ = ∫ t, (∫ u, G (t, u) ∂μ) ∂μ := hswap _ = _ := by apply integral_congr_ae filter_upwards [] with t dsimp [G] rw [integral_const_mul] -
power_bernstein_L1_le_curvature_errortheorem — For a real power above one, the L1 error of its finite Bernstein cell density is bounded by the curvature-weighted adjacent-threshold error.hypothesesN :ℕhN :0 < Ns :ℝhs :1 < sconclusionProof (Lean source)
theorem power_bernstein_L1_le_curvature_error {N : ℕ} (hN : 0 < N) {s : ℝ} (hs : 1 < s) : (∫ u in Icc (0 : ℝ) 1, |bernsteinCell N (powerCell N s) u - powerDensity s u| ∂volume) ≤ ∫ t in Icc (0 : ℝ) 1, powerCurvature s t * sqrt (2 * t / N) ∂volume := by let I : Set ℝ := Icc 0 1 let μ : Measure ℝ := volume.restrict I have hr : IntervalIntegrable (fun x : ℝ => x ^ (s - 2)) volume 0 1 := intervalIntegral.intervalIntegrable_rpow' (by linarith) have hr' : IntervalIntegrable (fun t : ℝ => (1 - t) ^ (s - 2)) volume 0 1 := by convert (hr.comp_sub_left 1).symm using 1 <;> norm_num have hq : Integrable (powerCurvature s) μ := by apply (intervalIntegrable_iff_integrableOn_Icc_of_le (by norm_num : (0 : ℝ) ≤ 1)).mp change IntervalIntegrable (fun t : ℝ => s * (s - 1) * (1 - t) ^ (s - 2)) volume 0 1 exact hr'.const_mul (s * (s - 1)) have hstep (u : ℝ) : Integrable (fun t => powerCurvature s t * (if t ≤ u then (1 : ℝ) else 0)) μ := by apply hq.mul_bdd (c := 1) · exact (Measurable.ite (measurableSet_le measurable_id measurable_const) measurable_const measurable_const).aestronglyMeasurable · filter_upwards [] with t split_ifs <;> simp have hhinge (u : ℝ) : Integrable (fun t => powerCurvature s t * bernsteinCell N (hingeCell N t) u) μ := by have hc : Continuous (fun t : ℝ => bernsteinCell N (hingeCell N t) u) := by unfold bernsteinCell hingeCell fun_prop obtain ⟨C, hC⟩ := isCompact_Icc.exists_bound_of_continuousOn (hc.continuousOn : ContinuousOn (fun t : ℝ => bernsteinCell N (hingeCell N t) u) I) apply hq.mul_bdd (c := C) · exact hc.aestronglyMeasurable · filter_upwards [ae_restrict_mem measurableSet_Icc] with t ht exact hC t ht have heq (u : ℝ) (hu : u ∈ I) : bernsteinCell N (powerCell N s) u - powerDensity s u = - ∫ t in I, powerCurvature s t * (bernsteinCell N (hingeCell N t) u - (if t ≤ u then (1 : ℝ) else 0)) ∂volume := by rw [bernsteinCell_power_eq_sub_curvature_hinge_integral hN hs u, powerDensity_eq_sub_curvature_integral hs hu] calc _ = -((∫ t in I, powerCurvature s t * bernsteinCell N (hingeCell N t) u ∂volume) - (∫ t in I, powerCurvature s t * (if t ≤ u then (1 : ℝ) else 0) ∂volume)) := by ring _ = _ := by rw [← integral_sub (hhinge u) (hstep u)] congr 1 apply integral_congr_ae filter_upwards [] with t ring calc (∫ u in I, |bernsteinCell N (powerCell N s) u - powerDensity s u| ∂volume) = ∫ u in I, |∫ t in I, powerCurvature s t * (bernsteinCell N (hingeCell N t) u - (if t ≤ u then (1 : ℝ) else 0)) ∂volume| ∂volume := by apply setIntegral_congr_fun measurableSet_Icc intro u hu dsimp rw [heq u hu, abs_neg] _ ≤ ∫ t in I, powerCurvature s t * (∫ u in I, |bernsteinCell N (hingeCell N t) u - (if t ≤ u then (1 : ℝ) else 0)| ∂volume) ∂volume := power_curvature_hinge_error_integral_le hs _ ≤ ∫ t in I, powerCurvature s t * sqrt (2 * t / N) ∂volume := by have hG := power_curvature_hinge_error_integrable (N := N) hs have hleft : Integrable (fun t => powerCurvature s t * (∫ u in I, |bernsteinCell N (hingeCell N t) u - (if t ≤ u then (1 : ℝ) else 0)| ∂volume)) μ := by have hG' := hG.integral_prod_left simp only [integral_const_mul] at hG' exact hG' have hroot : Integrable (fun t => sqrt (2 * t / N)) μ := by apply Continuous.integrableOn_Icc fun_prop have hright : Integrable (fun t => powerCurvature s t * sqrt (2 * t / N)) μ := by apply hq.mul_bdd (c := 2) hroot.aestronglyMeasurable filter_upwards [ae_restrict_mem measurableSet_Icc] with t ht rw [Real.norm_eq_abs, abs_of_nonneg (Real.sqrt_nonneg _)] have hNr : (0 : ℝ) < N := by exact_mod_cast hN have harg : 2 * t / (N : ℝ) ≤ 4 := by apply (div_le_iff₀ hNr).mpr have hN1 : (1 : ℝ) ≤ N := by exact_mod_cast hN nlinarith [ht.2] calc _ ≤ sqrt 4 := Real.sqrt_le_sqrt harg _ = 2 := by norm_num apply integral_mono_ae hleft hright filter_upwards [ae_restrict_mem measurableSet_Icc] with t ht exact mul_le_mul_of_nonneg_left (bernsteinCell_hinge_indicator_L1 hN ht) (by unfold powerCurvature exact mul_nonneg (mul_nonneg (by linarith) (by linarith)) (Real.rpow_nonneg (by linarith [ht.2]) _)) -
power_bernstein_L1_onetheorem — For a positive sample size, the Bernstein kernel of first-power cells agrees with the constant unit density in L1.hypothesesN :ℕhN :0 < Nconclusion= 0Proof (Lean source)
theorem power_bernstein_L1_one {N : ℕ} (hN : 0 < N) : (∫ u in Icc (0 : ℝ) 1, |bernsteinCell N (powerCell N 1) u - powerDensity 1 u| ∂volume) = 0 := by have hNr : (N : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt hN) have hcell (j : Fin N) : powerCell N 1 j = 1 / N := by unfold powerCell simp only [Real.rpow_one] field_simp ring have hbern (u : ℝ) : bernsteinCell N (powerCell N 1) u = 1 := by simp_rw [bernsteinCell, hcell] have hsum : (∑ j : Fin N, (choose (N - 1) (j : ℕ) : ℝ) * u ^ (j : ℕ) * (1 - u) ^ (N - 1 - (j : ℕ))) = 1 := by have hpow := add_pow u (1 - u) (N - 1) rw [show N - 1 + 1 = N by omega, ← Fin.sum_univ_eq_sum_range] at hpow convert hpow.symm using 1 · apply Finset.sum_congr rfl intro j hj ring · ring calc (N : ℝ) * ∑ j : Fin N, (1 / N) * (choose (N - 1) (j : ℕ) : ℝ) * u ^ (j : ℕ) * (1 - u) ^ (N - 1 - (j : ℕ)) = N * ((1 / N) * ∑ j : Fin N, (choose (N - 1) (j : ℕ) : ℝ) * u ^ (j : ℕ) * (1 - u) ^ (N - 1 - (j : ℕ))) := by congr 1 rw [Finset.mul_sum] apply Finset.sum_congr rfl intro j hj ring _ = N * (1 / N) * ∑ j : Fin N, (choose (N - 1) (j : ℕ) : ℝ) * u ^ (j : ℕ) * (1 - u) ^ (N - 1 - (j : ℕ)) := by ring _ = 1 := by rw [hsum]; field_simp have hdens (u : ℝ) (hu : u ∈ Icc (0 : ℝ) 1) : powerDensity 1 u = 1 := by simp [powerDensity, Real.rpow_zero] have hzero : ∀ u ∈ Icc (0 : ℝ) 1, |bernsteinCell N (powerCell N 1) u - powerDensity 1 u| = 0 := by intro u hu rw [hbern u, hdens u hu] norm_num rw [setIntegral_congr_fun measurableSet_Icc hzero] simp -
power_bernstein_L1_largetheorem — For a positive sample size and power greater than the sample size, the unit-density bound gives the claimed L1 estimate.Proof (Lean source)
theorem power_bernstein_L1_large {N : ℕ} (hN : 0 < N) {s : ℝ} (hs : (N : ℝ) < s) : (∫ u in Icc (0 : ℝ) 1, |bernsteinCell N (powerCell N s) u - powerDensity s u| ∂volume) ≤ 2 * sqrt (s / N) := by have hNr : (0 : ℝ) < N := by exact_mod_cast hN have hs1 : 1 ≤ s := by have : (1 : ℝ) ≤ N := by exact_mod_cast hN linarith have hb : Continuous (bernsteinCell N (powerCell N s)) := by unfold bernsteinCell fun_prop have hd : Continuous (powerDensity s) := by unfold powerDensity exact continuous_const.mul ((Real.continuous_rpow_const (by linarith : 0 ≤ s - 1)).comp (continuous_const.sub continuous_id)) have hib : IntegrableOn (bernsteinCell N (powerCell N s)) (Icc (0 : ℝ) 1) volume := hb.integrableOn_Icc have hid : IntegrableOn (powerDensity s) (Icc (0 : ℝ) 1) volume := hd.integrableOn_Icc have hiabs : IntegrableOn (fun u => |bernsteinCell N (powerCell N s) u - powerDensity s u|) (Icc (0 : ℝ) 1) volume := by apply Continuous.integrableOn_Icc exact (hb.sub hd).abs have hiadd : IntegrableOn (fun u => bernsteinCell N (powerCell N s) u + powerDensity s u) (Icc (0 : ℝ) 1) volume := hib.add hid have hbound : (∫ u in Icc (0 : ℝ) 1, |bernsteinCell N (powerCell N s) u - powerDensity s u| ∂volume) ≤ 2 := by calc (∫ u in Icc (0 : ℝ) 1, |bernsteinCell N (powerCell N s) u - powerDensity s u| ∂volume) ≤ ∫ u in Icc (0 : ℝ) 1, (bernsteinCell N (powerCell N s) u + powerDensity s u) ∂volume := by apply setIntegral_mono_on hiabs hiadd measurableSet_Icc intro u hu have hbu := bernsteinCell_nonneg (N := N) (a := powerCell N s) (fun j => powerCell_nonneg hs1 j) hu have hdu : 0 ≤ powerDensity s u := by unfold powerDensity exact mul_nonneg (by linarith) (Real.rpow_nonneg (by linarith [hu.2]) _) rw [abs_le] constructor <;> linarith _ = 2 := by rw [integral_add hib hid, integral_bernsteinCell hN (powerCell N s) (sum_powerCell hN hs1), integral_powerDensity hs1] norm_num have hratio : 1 ≤ s / N := (le_div_iff₀ hNr).2 (by nlinarith) have hsqrt : 1 ≤ sqrt (s / N) := by simpa using Real.sqrt_le_sqrt hratio nlinarith -
power_bernstein_L1_smalltheorem — For a positive sample size and power between one and the sample size, the adjacent-order-statistic coupling gives the claimed L1 estimate.Proof (Lean source)
theorem power_bernstein_L1_small {N : ℕ} (hN : 0 < N) {s : ℝ} (hs : 1 ≤ s) (hsmall : s ≤ N) : (∫ u in Icc (0 : ℝ) 1, |bernsteinCell N (powerCell N s) u - powerDensity s u| ∂volume) ≤ 2 * sqrt (s / N) := by rcases eq_or_lt_of_le hs with rfl | hs' · rw [power_bernstein_L1_one hN] positivity · have hNr : (0 : ℝ) < N := by exact_mod_cast hN calc (∫ u in Icc (0 : ℝ) 1, |bernsteinCell N (powerCell N s) u - powerDensity s u| ∂volume) ≤ ∫ t in Icc (0 : ℝ) 1, powerCurvature s t * sqrt (2 * t / N) ∂volume := power_bernstein_L1_le_curvature_error hN hs' _ = sqrt (2 / N) * (∫ t in Icc (0 : ℝ) 1, powerCurvature s t * sqrt t ∂volume) := by rw [← integral_const_mul] apply integral_congr_ae filter_upwards [] with t rw [show 2 * t / (N : ℝ) = (2 / N) * t by ring, Real.sqrt_mul (by positivity : 0 ≤ (2 : ℝ) / N)] ring _ ≤ sqrt (2 / N) * sqrt s := mul_le_mul_of_nonneg_left (integral_powerCurvature_mul_sqrt_le hs') (Real.sqrt_nonneg _) _ ≤ 2 * sqrt (s / N) := by calc sqrt (2 / N) * sqrt s = sqrt (2 * s / N) := by rw [show 2 * s / (N : ℝ) = (2 / N) * s by ring, Real.sqrt_mul (by positivity : 0 ≤ (2 : ℝ) / N)] _ ≤ sqrt (4 * s / N) := by apply Real.sqrt_le_sqrt apply (div_le_div_iff_of_pos_right hNr).mpr nlinarith _ = 2 * sqrt (s / N) := by rw [show 4 * s / (N : ℝ) = 4 * (s / N) by ring, Real.sqrt_mul (by norm_num : (0 : ℝ) ≤ 4)] norm_num
ReplacementLaw 1 core · 5 supporting Replacing one coordinate of an iid tuple by an independent observation preserves its product distribution. ★ integral_coordinateVariance_eq_half_replacement_sq
Independent replacement under a finite product law
Replacing one coordinate of an iid tuple by an independent observation preserves its product distribution. This measure statement isolates the exchangeability step used by rank-statistic variance bounds.
An iid sampling law, selected coordinate, and square-integrable statistic give an expected replacement variance equal to half its expected squared independent replacement change.
Formal statement
Proof (Lean source)
5 supporting declarations (lemmas, instances)
-
measurable_coordinateReplace_pairtheorem — For a finite tuple and an independent replacement value, updating one coordinate is a measurable map of the tuple and the value.hypothesesconclusionProof (Lean source)
@[fun_prop] theorem measurable_coordinateReplace_pair {N : ℕ} {α : Type*} [MeasurableSpace α] (i : Fin N) : Measurable (fun p : (Fin N → α) × α => coordinateReplace i p.1 p.2) := by classical apply measurable_pi_iff.mpr intro j by_cases h : j = i · subst j simpa [coordinateReplace] using (measurable_snd : Measurable (fun p : (Fin N → α) × α => p.2)) · have hm : Measurable (fun p : (Fin N → α) × α => p.1 j) := by fun_prop simpa [coordinateReplace, h] using hm -
coordinateReplace_map_prodtheorem — If a finite tuple has iid law μ and y is an independent draw from μ, the tuple obtained by replacing coordinate i with y has the original iid law.hypothesesconclusionMeasure.map (fun p : (Fin N → α) × α => coordinateReplace i p.1 p.2) ((Measure.pi (fun _ : Fin N => μ)).prod μ)= Measure.pi (fun _ : Fin N => μ)Proof (Lean source)
theorem coordinateReplace_map_prod {N : ℕ} {α : Type*} [MeasurableSpace α] (μ : Measure α) [IsProbabilityMeasure μ] (i : Fin N) : Measure.map (fun p : (Fin N → α) × α => coordinateReplace i p.1 p.2) ((Measure.pi (fun _ : Fin N => μ)).prod μ) = Measure.pi (fun _ : Fin N => μ) := by classical apply (Measure.pi_eq (μ := fun _ : Fin N => μ) (fun s hs => ?_)).symm let t : Fin N → Set α := fun j => if j = i then Set.univ else s j have hpre : (fun p : (Fin N → α) × α => coordinateReplace i p.1 p.2) ⁻¹' (Set.univ.pi s) = (Set.univ.pi t) ×ˢ s i := by ext p simp only [Set.mem_preimage, Set.mem_pi, Set.mem_univ, forall_true_left, Set.mem_prod, t, coordinateReplace] constructor · intro hp constructor · intro j by_cases h : j = i · simp [h] · simpa [h] using hp j · simpa using hp i · rintro ⟨hp, hi⟩ j by_cases h : j = i · simpa [h] using hi · simpa [h] using hp j rw [Measure.map_apply (measurable_coordinateReplace_pair i) (MeasurableSet.univ_pi hs), hpre, Measure.prod_prod, Measure.pi_pi] dsimp [t] rw [show (∏ j : Fin N, μ (if j = i then Set.univ else s j)) = ∏ j ∈ Finset.univ.erase i, μ (s j) by rw [← Finset.prod_erase_mul (s := univ) (f := fun j => μ (if j = i then Set.univ else s j)) (a := i) (by simp)] simp only [if_true, measure_univ, mul_one] apply Finset.prod_congr rfl intro j hj have hji : j ≠ i := Finset.ne_of_mem_erase hj simp [hji]] exact Finset.prod_erase_mul univ (fun j : Fin N => μ (s j)) (by simp) -
integral_coordinateReplace_prodtheorem — Integrating an integrable function of an iid tuple is unchanged when one coordinate is replaced by an independent draw from the same law.hypothesesN :ℕα :Type*μ :i :Fin Nf :(Fin N → α) → ℝhf :Integrable f (Measure.pi (fun _ : Fin N => μ))conclusion= ∫ x, f x ∂Measure.pi (fun _ : Fin N => μ)Proof (Lean source)
theorem integral_coordinateReplace_prod {N : ℕ} {α : Type*} [MeasurableSpace α] (μ : Measure α) [IsProbabilityMeasure μ] (i : Fin N) (f : (Fin N → α) → ℝ) (hf : Integrable f (Measure.pi (fun _ : Fin N => μ))) : (∫ p : (Fin N → α) × α, f (coordinateReplace i p.1 p.2) ∂(Measure.pi (fun _ : Fin N => μ)).prod μ) = ∫ x, f x ∂Measure.pi (fun _ : Fin N => μ) := by have hfm : AEStronglyMeasurable f (Measure.map (fun p : (Fin N → α) × α => coordinateReplace i p.1 p.2) ((Measure.pi (fun _ : Fin N => μ)).prod μ)) := by rw [coordinateReplace_map_prod μ i] exact hf.aestronglyMeasurable rw [← integral_map (measurable_coordinateReplace_pair i).aemeasurable hfm, coordinateReplace_map_prod μ i] -
integral_coordinateVariance_eq_half_double_replacement_sqtheorem — For a square-integrable statistic of an iid finite tuple, the expected conditional variance at one coordinate is half the expected squared difference between two independent replacements of that coordinate.hypothesesconclusion= (1 / 2 : ℝ) * ∫ x, ∫ y, ∫ z, (F (coordinateReplace i x y) - F (coordinateReplace i x z)) ^ 2 ∂μ ∂μ ∂Measure.pi (fun _ : Fin N => μ)Proof (Lean source)
theorem integral_coordinateVariance_eq_half_double_replacement_sq {N : ℕ} {α : Type*} [MeasurableSpace α] (μ : Measure α) [IsProbabilityMeasure μ] (i : Fin N) (F : (Fin N → α) → ℝ) (hF : MemLp F 2 (Measure.pi (fun _ : Fin N => μ))) : (∫ x, variance (fun y => F (coordinateReplace i x y)) μ ∂Measure.pi (fun _ : Fin N => μ)) = (1 / 2 : ℝ) * ∫ x, ∫ y, ∫ z, (F (coordinateReplace i x y) - F (coordinateReplace i x z)) ^ 2 ∂μ ∂μ ∂Measure.pi (fun _ : Fin N => μ) := by -- Derive MemLp of the replacement section for almost every x from the -- product L² hypothesis. Apply variance_eq_half_integral_prod_sq_sub -- on those sections, then use Fubini for the triple square integral. let ν : Measure (Fin N → α) := Measure.pi (fun _ => μ) let H : (Fin N → α) × α → ℝ := fun p => F (coordinateReplace i p.1 p.2) have hmp : MeasurePreserving (fun p : (Fin N → α) × α => coordinateReplace i p.1 p.2) (ν.prod μ) ν := by refine ⟨measurable_coordinateReplace_pair i, ?_⟩ exact coordinateReplace_map_prod μ i have hH : MemLp H 2 (ν.prod μ) := hF.comp_measurePreserving hmp have hslices : ∀ᵐ x ∂ν, MemLp (fun y => H (x, y)) 2 μ := by filter_upwards [hH.aestronglyMeasurable.prodMk_left, hH.integrable_sq.prod_right_ae] with x hxm hxi exact (memLp_two_iff_integrable_sq hxm).2 hxi change (∫ x, variance (fun y => H (x, y)) μ ∂ν) = (1 / 2 : ℝ) * ∫ x, ∫ y, ∫ z, (H (x, y) - H (x, z)) ^ 2 ∂μ ∂μ ∂ν rw [← integral_const_mul] apply integral_congr_ae filter_upwards [hslices] with x hx rw [variance_eq_half_integral_prod_sq_sub μ (fun y => H (x, y)) hx] congr 1 have hpair : Integrable (fun p : α × α => (H (x, p.1) - H (x, p.2)) ^ 2) (μ.prod μ) := ((hx.comp_fst μ).sub (hx.comp_snd μ)).integrable_sq exact integral_prod _ hpair -
integral_double_replacement_sq_eq_replacement_sqtheorem — For a square-integrable statistic of an iid finite tuple, averaging the squared difference of two independent coordinate replacements equals averaging the squared difference between the original tuple and one replacement.hypothesesconclusion(∫ x, ∫ y, ∫ z, (F (coordinateReplace i x y) - F (coordinateReplace i x z)) ^ 2 ∂μ ∂μ ∂Measure.pi (fun _ : Fin N => μ))= ∫ x, ∫ y, (F x - F (coordinateReplace i x y)) ^ 2 ∂μ ∂Measure.pi (fun _ : Fin N => μ)Proof (Lean source)
theorem integral_double_replacement_sq_eq_replacement_sq {N : ℕ} {α : Type*} [MeasurableSpace α] (μ : Measure α) [IsProbabilityMeasure μ] (i : Fin N) (F : (Fin N → α) → ℝ) (hF : MemLp F 2 (Measure.pi (fun _ : Fin N => μ))) : (∫ x, ∫ y, ∫ z, (F (coordinateReplace i x y) - F (coordinateReplace i x z)) ^ 2 ∂μ ∂μ ∂Measure.pi (fun _ : Fin N => μ)) = ∫ x, ∫ y, (F x - F (coordinateReplace i x y)) ^ 2 ∂μ ∂Measure.pi (fun _ : Fin N => μ) := by -- Replacing the original tuple with the independent draw preserves its law. -- Lift that measure-preserving map across the other independent draw, then -- apply Fubini and collapse the two updates at the same coordinate. let ν : Measure (Fin N → α) := Measure.pi (fun _ => μ) let R : (Fin N → α) × α → (Fin N → α) := fun p => coordinateReplace i p.1 p.2 let G : (Fin N → α) × α → ℝ := fun p => (F p.1 - F (coordinateReplace i p.1 p.2)) ^ 2 have hR : MeasurePreserving R (ν.prod μ) ν := by refine ⟨measurable_coordinateReplace_pair i, ?_⟩ exact coordinateReplace_map_prod μ i have hFR : MemLp (fun p : (Fin N → α) × α => F (R p)) 2 (ν.prod μ) := hF.comp_measurePreserving hR have hG : Integrable G (ν.prod μ) := by exact ((hF.comp_fst μ).sub hFR).integrable_sq have hRR : MeasurePreserving (map R id) ((ν.prod μ).prod μ) (ν.prod μ) := hR.prod (MeasurePreserving.id μ) have hGcomp : Integrable (fun p : ((Fin N → α) × α) × α => G (R p.1, p.2)) ((ν.prod μ).prod μ) := by exact hRR.integrable_comp_of_integrable hG have hmap : (∫ p : ((Fin N → α) × α) × α, G (R p.1, p.2) ∂((ν.prod μ).prod μ)) = ∫ q, G q ∂(ν.prod μ) := by have hm : AEStronglyMeasurable G (Measure.map (map R id) ((ν.prod μ).prod μ)) := by rw [hRR.map_eq] exact hG.aestronglyMeasurable change (∫ p : ((Fin N → α) × α) × α, G ((map R id) p) ∂((ν.prod μ).prod μ)) = ∫ q, G q ∂(ν.prod μ) rw [← integral_map hRR.measurable.aemeasurable hm, hRR.map_eq] have hiter : (∫ x, ∫ z, ∫ y, G (R (x, z), y) ∂μ ∂μ ∂ν) = ∫ x, ∫ y, G (x, y) ∂μ ∂ν := by calc _ = ∫ p : (Fin N → α) × α, ∫ y, G (R p, y) ∂μ ∂(ν.prod μ) := by exact (integral_prod _ hGcomp.integral_prod_left).symm _ = ∫ p : ((Fin N → α) × α) × α, G (R p.1, p.2) ∂((ν.prod μ).prod μ) := by exact (integral_prod _ hGcomp).symm _ = ∫ q, G q ∂(ν.prod μ) := hmap _ = ∫ x, ∫ y, G (x, y) ∂μ ∂ν := integral_prod _ hG simpa only [G, R, coordinateReplace, Function.update_idem] using hiter
ReplacementVariance 1 core · 7 supporting This module applies independent coordinate replacement to bound the variance of a bounded rank-weighted concomitant by its squared cell weights. ★ variance_rankConcomitant_le_twice_sum_sq
Tensorized variance of rank-weighted concomitants
This module applies independent coordinate replacement to bound the variance of a bounded rank-weighted concomitant by its squared cell weights.
For an iid marked law with continuous sorting-coordinate CDF and unit-bounded marks, and cell weights that are nonnegative and antitone, the concomitant variance is at most twice the squared-weight sum.
Formal statement
Proof (Lean source)
7 supporting declarations (lemmas, instances)
-
rankConcomitant_replacement_sensitivity_aetheorem — Under a continuous sorting-coordinate CDF, almost every original sample and independent coordinate replacement have distinct coordinates and bounded marks, so the pointwise rank replacement sensitivity applies.hypothesesN :ℕμ :Measure (ℝ × ℝ)hcont :hmark :∀ᵐ p ∂μ, p.2 ∈ Icc (0 : ℝ) 1a :Fin N → ℝha :∀ j, 0 ≤ a jhmono :Antitone ai :Fin Nconclusion- rankConcomitant a (coordinateReplace i p.1 p.2)|Proof (Lean source)
theorem rankConcomitant_replacement_sensitivity_ae {N : ℕ} (μ : Measure (ℝ × ℝ)) [IsProbabilityMeasure μ] (hcont : Continuous (fun t => cdf (μ.map Prod.fst) t)) (hmark : ∀ᵐ p ∂μ, p.2 ∈ Icc (0 : ℝ) 1) (a : Fin N → ℝ) (ha : ∀ j, 0 ≤ a j) (hmono : Antitone a) (i : Fin N) : ∀ᵐ p : (Fin N → ℝ × ℝ) × (ℝ × ℝ) ∂(Measure.pi (fun _ : Fin N => μ)).prod μ, |rankConcomitant a p.1 - rankConcomitant a (coordinateReplace i p.1 p.2)| ≤ a (rankPosition p.1 i) + a (rankPosition (coordinateReplace i p.1 p.2) i) := by -- Pull tie-free events back through the two product marginals, and use -- rankConcomitant_replacement_sensitivity on their intersection. let P : Measure (Fin N → ℝ × ℝ) := Measure.pi (fun _ : Fin N => μ) let R : Measure ((Fin N → ℝ × ℝ) × (ℝ × ℝ)) := P.prod μ let F : (Fin N → ℝ × ℝ) → (Fin N → ℝ) := fun x k => cdf (μ.map Prod.fst) (x k).1 have hF : Measurable F := by apply measurable_pi_iff.mpr intro k exact hcont.measurable.comp (measurable_fst.comp (measurable_pi_apply k)) have hcoord : ∀ᵐ x ∂P, Injective (F x) := by have hu := iid_uniform_coordinates_injective_ae (N := N) rw [← cdf_transport_iid μ hcont] at hu exact ae_of_ae_map hF.aemeasurable hu have hinj : ∀ᵐ x ∂P, Injective (fun k => (x k).1) := by filter_upwards [hcoord] with x hx j k hjk apply hx exact congrArg (fun t : ℝ => cdf (μ.map Prod.fst) t) hjk have hmarkP : ∀ᵐ x ∂P, ∀ j : Fin N, (x j).2 ∈ Icc (0 : ℝ) 1 := by apply Filter.eventually_all.mpr intro j exact (Measure.tendsto_eval_ae_ae (μ := fun _ : Fin N => μ) (i := j)).eventually hmark have hfst : MeasurePreserving (Prod.fst : (Fin N → ℝ × ℝ) × (ℝ × ℝ) → _) R P := measurePreserving_fst have hsnd : MeasurePreserving (Prod.snd : (Fin N → ℝ × ℝ) × (ℝ × ℝ) → _) R μ := measurePreserving_snd have hreplace : MeasurePreserving (fun p : (Fin N → ℝ × ℝ) × (ℝ × ℝ) => coordinateReplace i p.1 p.2) R P := ⟨measurable_coordinateReplace_pair i, coordinateReplace_map_prod μ i⟩ have hinj₁ : ∀ᵐ p ∂ R, Injective (fun j => (p.1 j).1) := by exact ae_of_ae_map hfst.aemeasurable (by rw [hfst.map_eq]; exact hinj) have hinj₂ : ∀ᵐ p ∂ R, Injective (fun j => ((coordinateReplace i p.1 p.2) j).1) := by exact ae_of_ae_map hreplace.aemeasurable (by rw [hreplace.map_eq]; exact hinj) have hm₁ : ∀ᵐ p ∂ R, ∀ j : Fin N, (p.1 j).2 ∈ Icc (0 : ℝ) 1 := by exact ae_of_ae_map hfst.aemeasurable (by rw [hfst.map_eq]; exact hmarkP) have hm₂ : ∀ᵐ p ∂ R, p.2.2 ∈ Icc (0 : ℝ) 1 := by exact ae_of_ae_map hsnd.aemeasurable (by rw [hsnd.map_eq]; exact hmark) filter_upwards [hinj₁, hinj₂, hm₁, hm₂] with p hp hp' hm hy exact rankConcomitant_replacement_sensitivity a ha hmono p.1 i p.2 hm hy hp hp' -
rankConcomitant_replacement_difference_sq_integrabletheorem — The squared change of a bounded rank concomitant after one independent coordinate replacement is integrable under the sample–replacement product law.hypothesesconclusionIntegrable (fun p : (Fin N → ℝ × ℝ) × (ℝ × ℝ) => (rankConcomitant a p.1 - rankConcomitant a (coordinateReplace i p.1 p.2)) ^ 2) ((Measure.pi (fun _ : Fin N => μ)).prod μ)Proof (Lean source)
theorem rankConcomitant_replacement_difference_sq_integrable {N : ℕ} (μ : Measure (ℝ × ℝ)) [IsProbabilityMeasure μ] (hmark : ∀ᵐ p ∂μ, p.2 ∈ Icc (0 : ℝ) 1) (a : Fin N → ℝ) (i : Fin N) : Integrable (fun p : (Fin N → ℝ × ℝ) × (ℝ × ℝ) => (rankConcomitant a p.1 - rankConcomitant a (coordinateReplace i p.1 p.2)) ^ 2) ((Measure.pi (fun _ : Fin N => μ)).prod μ) := by -- Pull square integrability of rankConcomitant along both projections; -- coordinateReplace_map_prod handles the resampled statistic. let P : Measure (Fin N → ℝ × ℝ) := Measure.pi (fun _ : Fin N => μ) let R : Measure ((Fin N → ℝ × ℝ) × (ℝ × ℝ)) := P.prod μ have hLp : MemLp (rankConcomitant a) 2 P := rankConcomitant_memLp_two μ hmark a have hfst : MeasurePreserving (Prod.fst : (Fin N → ℝ × ℝ) × (ℝ × ℝ) → _) R P := measurePreserving_fst have hreplace : MeasurePreserving (fun p : (Fin N → ℝ × ℝ) × (ℝ × ℝ) => coordinateReplace i p.1 p.2) R P := ⟨measurable_coordinateReplace_pair i, coordinateReplace_map_prod μ i⟩ have h₁ : MemLp (fun p : (Fin N → ℝ × ℝ) × (ℝ × ℝ) => rankConcomitant a p.1) 2 R := hLp.comp_measurePreserving hfst have h₂ : MemLp (fun p : (Fin N → ℝ × ℝ) × (ℝ × ℝ) => rankConcomitant a (coordinateReplace i p.1 p.2)) 2 R := hLp.comp_measurePreserving hreplace have hdiff : MemLp (fun p : (Fin N → ℝ × ℝ) × (ℝ × ℝ) => rankConcomitant a p.1 - rankConcomitant a (coordinateReplace i p.1 p.2)) 2 R := h₁.sub h₂ exact (memLp_two_iff_integrable_sq hdiff.aestronglyMeasurable).mp hdiff -
rankPosition_weight_sq_integrabletheorem — Under a continuous sorting-coordinate CDF, the square of a fixed observation's rank weight is integrable for any finite real weight vector.Proof (Lean source)
theorem rankPosition_weight_sq_integrable {N : ℕ} (μ : Measure (ℝ × ℝ)) [IsProbabilityMeasure μ] (hcont : Continuous (fun t => cdf (μ.map fst) t)) (a : Fin N → ℝ) (i : Fin N) : Integrable (fun x : Fin N → ℝ × ℝ => (a (rankPosition x i)) ^ 2) (Measure.pi (fun _ : Fin N => μ)) := by classical let P : Measure (Fin N → ℝ × ℝ) := Measure.pi (fun _ : Fin N => μ) let F : (Fin N → ℝ × ℝ) → (Fin N → ℝ) := fun x k => cdf (μ.map fst) (x k).1 have hF : Measurable F := by apply measurable_pi_iff.mpr intro k exact hcont.measurable.comp (measurable_fst.comp (measurable_pi_apply k)) have hcoord : ∀ᵐ x ∂P, Injective (F x) := by have hu := iid_uniform_coordinates_injective_ae (N := N) rw [← cdf_transport_iid μ hcont] at hu exact ae_of_ae_map hF.aemeasurable hu have hinj : ∀ᵐ x ∂P, Injective (fun k => (x k).1) := by filter_upwards [hcoord] with x hx j k hjk apply hx exact congrArg (fun t : ℝ => cdf (μ.map fst) t) hjk have hrank (j : Fin N) : NullMeasurableSet {x | rankPosition x i = j} P := by let E : Set (Fin N → ℝ × ℝ) := {x | ((Finset.univ : Finset (Fin N)).filter (fun k => (x k).1 < (x i).1)).card = j.val} have hE : MeasurableSet E := by dsimp [E] apply measurableSet_eq_fun · simp_rw [Finset.card_filter] apply Finset.measurable_sum intro k _ apply Measurable.ite · exact measurableSet_lt (measurable_fst.comp (measurable_pi_apply k)) (measurable_fst.comp (measurable_pi_apply i)) · exact measurable_const · exact measurable_const · exact measurable_const apply hE.nullMeasurableSet.congr filter_upwards [hinj] with x hx apply propext change (((Finset.univ : Finset (Fin N)).filter (fun k => (x k).1 < (x i).1)).card = j.val) ↔ rankPosition x i = j rw [← rankPosition_val_eq_card_lt x i hx] exact Fin.ext_iff.symm have hr : AEMeasurable (fun x : Fin N → ℝ × ℝ => rankPosition x i) P := by apply NullMeasurable.aemeasurable change @Measurable (NullMeasurableSpace (Fin N → ℝ × ℝ) P) (Fin N) _ _ (fun x => rankPosition x i) apply measurable_to_countable' intro j exact hrank j have hstrong : AEStronglyMeasurable (fun x : Fin N → ℝ × ℝ => (a (rankPosition x i)) ^ 2) P := ((measurable_of_countable (fun j : Fin N => (a j) ^ 2)).comp_aemeasurable hr).aestronglyMeasurable apply Integrable.of_bound hstrong (∑ j : Fin N, |(a j) ^ 2|) filter_upwards [] with x rw [Real.norm_eq_abs] exact Finset.single_le_sum (fun j _ => abs_nonneg ((a j) ^ 2)) (Finset.mem_univ (rankPosition x i)) -
integral_replaced_rankPosition_weight_sqtheorem — Independent replacement preserves the expected squared weight of the replaced observation's rank.hypothesesconclusion(∫ p : (Fin N → ℝ × ℝ) × (ℝ × ℝ), (a (rankPosition (coordinateReplace i p.1 p.2) i)) ^ 2 ∂(Measure.pi (fun _ : Fin N => μ)).prod μ)= ∫ x, (a (rankPosition x i)) ^ 2 ∂Measure.pi (fun _ : Fin N => μ)Proof (Lean source)
theorem integral_replaced_rankPosition_weight_sq {N : ℕ} (μ : Measure (ℝ × ℝ)) [IsProbabilityMeasure μ] (hcont : Continuous (fun t => cdf (μ.map fst) t)) (a : Fin N → ℝ) (i : Fin N) : (∫ p : (Fin N → ℝ × ℝ) × (ℝ × ℝ), (a (rankPosition (coordinateReplace i p.1 p.2) i)) ^ 2 ∂(Measure.pi (fun _ : Fin N => μ)).prod μ) = ∫ x, (a (rankPosition x i)) ^ 2 ∂Measure.pi (fun _ : Fin N => μ) := by exact integral_coordinateReplace_prod μ i (fun x => (a (rankPosition x i)) ^ 2) (rankPosition_weight_sq_integrable μ hcont a i) -
rankConcomitant_replacement_sq_aetheorem — Almost surely under the sample–replacement product law, the squared change in a rank concomitant is at most twice the sum of the squared weights at the removed and inserted ranks.hypothesesN :ℕμ :Measure (ℝ × ℝ)hcont :hmark :∀ᵐ p ∂μ, p.2 ∈ Icc (0 : ℝ) 1a :Fin N → ℝha :∀ j, 0 ≤ a jhmono :Antitone ai :Fin Nconclusion∀ᵐ p : (Fin N → ℝ × ℝ) × (ℝ × ℝ) ∂(Measure.pi (fun _ : Fin N => μ)).prod μ, (rankConcomitant a p.1 - rankConcomitant a (coordinateReplace i p.1 p.2)) ^ 2Proof (Lean source)
theorem rankConcomitant_replacement_sq_ae {N : ℕ} (μ : Measure (ℝ × ℝ)) [IsProbabilityMeasure μ] (hcont : Continuous (fun t => cdf (μ.map fst) t)) (hmark : ∀ᵐ p ∂μ, p.2 ∈ Icc (0 : ℝ) 1) (a : Fin N → ℝ) (ha : ∀ j, 0 ≤ a j) (hmono : Antitone a) (i : Fin N) : ∀ᵐ p : (Fin N → ℝ × ℝ) × (ℝ × ℝ) ∂(Measure.pi (fun _ : Fin N => μ)).prod μ, (rankConcomitant a p.1 - rankConcomitant a (coordinateReplace i p.1 p.2)) ^ 2 ≤ 2 * ((a (rankPosition p.1 i)) ^ 2 + (a (rankPosition (coordinateReplace i p.1 p.2) i)) ^ 2) := by filter_upwards [rankConcomitant_replacement_sensitivity_ae μ hcont hmark a ha hmono i] with p hp have h₁ := ha (rankPosition p.1 i) have h₂ := ha (rankPosition (coordinateReplace i p.1 p.2) i) have hprod : 0 ≤ |rankConcomitant a p.1 - rankConcomitant a (coordinateReplace i p.1 p.2)| * (a (rankPosition p.1 i) + a (rankPosition (coordinateReplace i p.1 p.2) i) - |rankConcomitant a p.1 - rankConcomitant a (coordinateReplace i p.1 p.2)|) := mul_nonneg (abs_nonneg _) (sub_nonneg.mpr hp) have hprod' : 0 ≤ (a (rankPosition p.1 i) + a (rankPosition (coordinateReplace i p.1 p.2) i)) * (a (rankPosition p.1 i) + a (rankPosition (coordinateReplace i p.1 p.2) i) - |rankConcomitant a p.1 - rankConcomitant a (coordinateReplace i p.1 p.2)|) := mul_nonneg (add_nonneg h₁ h₂) (sub_nonneg.mpr hp) nlinarith [sq_nonneg (a (rankPosition p.1 i) - a (rankPosition (coordinateReplace i p.1 p.2) i)), sq_abs (rankConcomitant a p.1 - rankConcomitant a (coordinateReplace i p.1 p.2))] -
integral_replacement_sq_le_four_rank_weight_sqtheorem — For an iid marked sample with a continuous sorting-coordinate CDF and unit-bounded marks, the mean squared change after resampling one observation is at most four times the mean squared weight at its original rank.hypothesesN :ℕμ :Measure (ℝ × ℝ)hcont :hmark :∀ᵐ p ∂μ, p.2 ∈ Icc (0 : ℝ) 1a :Fin N → ℝha :∀ j, 0 ≤ a jhmono :Antitone ai :Fin Nconclusion(∫ x, ∫ y, (rankConcomitant a x - rankConcomitant a (coordinateReplace i x y)) ^ 2 ∂μ ∂Measure.pi (fun _ : Fin N => μ))≤ 4 * ∫ x, (a (rankPosition x i)) ^ 2 ∂Measure.pi (fun _ : Fin N => μ)Proof (Lean source)
theorem integral_replacement_sq_le_four_rank_weight_sq {N : ℕ} (μ : Measure (ℝ × ℝ)) [IsProbabilityMeasure μ] (hcont : Continuous (fun t => cdf (μ.map Prod.fst) t)) (hmark : ∀ᵐ p ∂μ, p.2 ∈ Icc (0 : ℝ) 1) (a : Fin N → ℝ) (ha : ∀ j, 0 ≤ a j) (hmono : Antitone a) (i : Fin N) : (∫ x, ∫ y, (rankConcomitant a x - rankConcomitant a (coordinateReplace i x y)) ^ 2 ∂μ ∂Measure.pi (fun _ : Fin N => μ)) ≤ 4 * ∫ x, (a (rankPosition x i)) ^ 2 ∂Measure.pi (fun _ : Fin N => μ) := by -- On the full-measure tie-free event, replacement sensitivity gives -- (Z(x)-Z(x^i_y))² ≤ 2(a(rank_i x)²+a(rank_i x^i_y)²). -- The law of x^i_y under the product measure is again the iid law, so -- both weight-square integrals are equal. let P : Measure (Fin N → ℝ × ℝ) := Measure.pi (fun _ : Fin N => μ) let R : Measure ((Fin N → ℝ × ℝ) × (ℝ × ℝ)) := P.prod μ let w : (Fin N → ℝ × ℝ) → ℝ := fun x => (a (rankPosition x i)) ^ 2 let w' : ((Fin N → ℝ × ℝ) × (ℝ × ℝ)) → ℝ := fun p => (a (rankPosition (coordinateReplace i p.1 p.2) i)) ^ 2 let d : ((Fin N → ℝ × ℝ) × (ℝ × ℝ)) → ℝ := fun p => (rankConcomitant a p.1 - rankConcomitant a (coordinateReplace i p.1 p.2)) ^ 2 have hw : Integrable w P := rankPosition_weight_sq_integrable μ hcont a i have hfst : MeasurePreserving (Prod.fst : ((Fin N → ℝ × ℝ) × (ℝ × ℝ)) → _) R P := measurePreserving_fst have hwfst : Integrable (fun p : (Fin N → ℝ × ℝ) × (ℝ × ℝ) => w p.1) R := hfst.integrable_comp_of_integrable hw have hreplace : MeasurePreserving (fun p : (Fin N → ℝ × ℝ) × (ℝ × ℝ) => coordinateReplace i p.1 p.2) R P := ⟨measurable_coordinateReplace_pair i, coordinateReplace_map_prod μ i⟩ have hw' : Integrable w' R := hreplace.integrable_comp_of_integrable hw have hd : Integrable d R := rankConcomitant_replacement_difference_sq_integrable μ hmark a i have hmono' : (∫ p : (Fin N → ℝ × ℝ) × (ℝ × ℝ), d p ∂(R)) ≤ ∫ p : (Fin N → ℝ × ℝ) × (ℝ × ℝ), 2 * (w p.1 + w' p) ∂(R) := by apply integral_mono_ae hd · exact (hwfst.add hw').const_mul 2 · exact rankConcomitant_replacement_sq_ae μ hcont hmark a ha hmono i have hleft : (∫ p : (Fin N → ℝ × ℝ) × (ℝ × ℝ), d p ∂(R)) = ∫ x, ∫ y, (rankConcomitant a x - rankConcomitant a (coordinateReplace i x y)) ^ 2 ∂μ ∂(P) := integral_prod _ hd have hfirst : (∫ p : (Fin N → ℝ × ℝ) × (ℝ × ℝ), w p.1 ∂(R)) = ∫ x, w x ∂(P) := by rw [integral_prod _ hwfst] simp have hsecond : (∫ p : (Fin N → ℝ × ℝ) × (ℝ × ℝ), w' p ∂(R)) = ∫ x, w x ∂(P) := by exact integral_replaced_rankPosition_weight_sq μ hcont a i rw [← hleft] calc (∫ p : (Fin N → ℝ × ℝ) × (ℝ × ℝ), d p ∂(R)) ≤ ∫ p : (Fin N → ℝ × ℝ) × (ℝ × ℝ), 2 * (w p.1 + w' p) ∂(R) := hmono' _ = 2 * ((∫ p : (Fin N → ℝ × ℝ) × (ℝ × ℝ), w p.1 ∂(R)) + ∫ p : (Fin N → ℝ × ℝ) × (ℝ × ℝ), w' p ∂(R)) := by rw [integral_const_mul, integral_add hwfst hw'] _ = 4 * ∫ x, w x ∂(P) := by rw [hfirst, hsecond]; ring -
integral_coordinateVariance_rankConcomitant_letheorem — For an iid marked sample with continuous sorting-coordinate CDF and marks in [0,1], the expected variance from resampling one coordinate is bounded by twice that coordinate's expected squared rank weight.hypothesesN :ℕμ :Measure (ℝ × ℝ)hcont :hmark :∀ᵐ p ∂μ, p.2 ∈ Icc (0 : ℝ) 1a :Fin N → ℝha :∀ j, 0 ≤ a jhmono :Antitone ai :Fin Nconclusion(∫ x, variance (fun y => rankConcomitant a (coordinateReplace i x y)) μ ∂Measure.pi (fun _ : Fin N => μ))≤ 2 * ∫ x, (a (rankPosition x i)) ^ 2 ∂Measure.pi (fun _ : Fin N => μ)Proof (Lean source)
theorem integral_coordinateVariance_rankConcomitant_le {N : ℕ} (μ : Measure (ℝ × ℝ)) [IsProbabilityMeasure μ] (hcont : Continuous (fun t => cdf (μ.map fst) t)) (hmark : ∀ᵐ p ∂μ, p.2 ∈ Icc (0 : ℝ) 1) (a : Fin N → ℝ) (ha : ∀ j, 0 ≤ a j) (hmono : Antitone a) (i : Fin N) : (∫ x, variance (fun y => rankConcomitant a (coordinateReplace i x y)) μ ∂Measure.pi (fun _ : Fin N => μ)) ≤ 2 * ∫ x, (a (rankPosition x i)) ^ 2 ∂Measure.pi (fun _ : Fin N => μ) := by -- Use the pairwise variance identity in the replacement coordinate, the -- sensitivity theorem on the full-measure tie-free/bounded-mark event, and -- symmetry of the original and resampled rank weights. rw [integral_coordinateVariance_eq_half_replacement_sq μ i (rankConcomitant a) (rankConcomitant_memLp_two μ hmark a)] have h := integral_replacement_sq_le_four_rank_weight_sq μ hcont hmark a ha hmono i nlinarith
UniformOrderCDF 1 core · 2 supporting The counting identity and binomial-tail law needed to identify an adjacent order-statistic mixture with a Bernstein hinge kernel. ★ uniform_sorted_cdf_eq_binomial_tail
Finite uniform order-statistic CDF
The counting identity and binomial-tail law needed to identify an adjacent order-statistic mixture with a Bernstein hinge kernel.
A sorted position and unit-interval threshold give the upper-binomial-tail formula for its iid uniform CDF.
Formal statement
Proof (Lean source)
2 supporting declarations (lemmas, instances)
-
sortedSample_le_iff_count_letheorem — The rth sorted coordinate is at most a threshold exactly when at least r+1 coordinates of the original finite tuple are at most that threshold.hypothesesconclusionsortedSample n x rProof (Lean source)
theorem sortedSample_le_iff_count_le {n : ℕ} (x : Fin n → ℝ) (r : Fin n) (u : ℝ) : sortedSample n x r ≤ u ↔ r.val + 1 ≤ ((Finset.univ : Finset (Fin n)).filter (fun i => x i ≤ u)).card := by -- Sorting is a permutation. In a monotone tuple, the initial segment below -- `u` contains position `r` iff its cardinality is at least `r+1`. let σ := Tuple.sort x have hcard : ((Finset.univ : Finset (Fin n)).filter (fun i => (x ∘ σ) i ≤ u)).card = ((Finset.univ : Finset (Fin n)).filter (fun i => x i ≤ u)).card := by apply Finset.card_equiv σ intro i simp [Function.comp_apply] have h := Tuple.lt_card_le_iff_apply_le_of_monotone (f := x ∘ σ) (a := u) (j := r) (Tuple.monotone_sort x) simpa only [sortedSample, σ, hcard, Fin.val_fin_lt, Nat.lt_iff_add_one_le] using h.symm -
uniform_count_le_masstheorem — In an iid sample of n unit uniforms, the number of coordinates at most u has the binomial mass with parameters n and u.hypothesesProof (Lean source)
theorem uniform_count_le_mass (n k : ℕ) {u : ℝ} (hu : u ∈ Icc (0 : ℝ) 1) : iidSample uniform01 n {x | ((Finset.univ : Finset (Fin n)).filter (fun i => x i ≤ u)).card = k} = ofReal ((Nat.choose n k : ℝ) * u ^ k * (1 - u) ^ (n - k)) := by -- `uniform_subset_lt_count_mass` proves the strict-threshold version. -- Each coordinate equals the fixed threshold only on a null set. haveI : IsProbabilityMeasure uniform01 := ⟨by simp [uniform01]⟩ have hsingle : uniform01 ({u} : Set ℝ) = 0 := by simp [uniform01] have hcoord (i : Fin n) : ∀ᵐ x ∂iidSample uniform01 n, x i ≠ u := by have hp := MeasureTheory.measurePreserving_eval (fun _ : Fin n => uniform01) i have hs : iidSample uniform01 n {x | x i = u} = 0 := by have hpre : (fun x : Fin n → ℝ => x i) ⁻¹' ({u} : Set ℝ) = {x | x i = u} := by ext x; simp calc iidSample uniform01 n {x | x i = u} = uniform01 ({u} : Set ℝ) := by rw [← hpre] exact hp.measure_preimage (measurableSet_singleton u).nullMeasurableSet _ = 0 := hsingle exact (ae_iff).2 (by simpa only [not_not] using hs) have hno : ∀ᵐ x ∂iidSample uniform01 n, ∀ i : Fin n, x i ≠ u := by simpa only [Filter.eventually_all] using hcoord have heq : {x : Fin n → ℝ | ((Finset.univ : Finset (Fin n)).filter (fun i => x i ≤ u)).card = k} =ᵐ[iidSample uniform01 n] {x : Fin n → ℝ | ((Finset.univ : Finset (Fin n)).filter (fun i => x i < u)).card = k} := by filter_upwards [hno] with x hx have hf : (Finset.univ : Finset (Fin n)).filter (fun i => x i ≤ u) = (Finset.univ : Finset (Fin n)).filter (fun i => x i < u) := by ext i simp [lt_iff_le_and_ne, hx i] change (((Finset.univ : Finset (Fin n)).filter (fun i => x i ≤ u)).card = k) = (((Finset.univ : Finset (Fin n)).filter (fun i => x i < u)).card = k) rw [hf] rw [measure_congr heq] simpa using uniform_subset_lt_count_mass (Finset.univ : Finset (Fin n)) k hu
UniformOrderMoments 1 core · 1 supporting The sorted-coordinate identities follow from the first-n spacing law and the simplex coordinate and cross moments in OrderStatisticMoments. ★ uniform_order_second_moment
First two moments of a uniform order statistic
The sorted-coordinate identities follow from the first-n spacing law and
the simplex coordinate and cross moments in OrderStatisticMoments.
The zero-based sorted index j corresponds to beta parameters j+1 and
n-j, as in the standard uniform order-statistic density.
For a positive sample size and zero-based sorted index, the corresponding uniform order statistic has second moment (j+1)(j+2)/((n+1)(n+2)).
Formal statement
Proof (Lean source)
1 supporting declaration (lemmas, instances)
-
uniform_order_meantheorem — For a positive sample size and zero-based sorted index, the corresponding uniform order statistic has mean (j+1)/(n+1).hypothesesconclusion(∫ x, sortedSample n x j ∂iidSample uniform01 n) = ((j : ℕ) + 1 : ℝ) / (n + 1)Proof (Lean source)
theorem uniform_order_mean {n : ℕ} (hn : 0 < n) (j : Fin n) : (∫ x, sortedSample n x j ∂iidSample uniform01 n) = ((j : ℕ) + 1 : ℝ) / (n + 1) := by have _ := hn classical let s := Iic j have hsorted (x : Fin n → ℝ) : sortedSample n x j = ∑ i ∈ s, firstNSpacings n x i := by simpa [s, prefixCoordinates, firstNSpacings_eq_orderedSpacings] using (congrFun (prefixCoordinates_orderedSpacings n (sortedSample n x)) j).symm have hsmeas : Measurable (fun z : Fin n → ℝ => ∑ i ∈ s, z i) := by fun_prop calc (∫ x, sortedSample n x j ∂iidSample uniform01 n) = ∫ z, (∑ i ∈ s, z i) ∂(iidSample uniform01 n).map (firstNSpacings n) := by rw [integral_map (firstNSpacings_aemeasurable_local n) hsmeas.aestronglyMeasurable] simp only [← hsorted] _ = (n.factorial : ℝ) * (∫ z, (∑ i ∈ s, z i) ∂volume.restrict (spacingSimplex n)) := by rw [uniform_firstN_spacings_law, integral_smul_measure] simp _ = ∑ i ∈ s, (1 : ℝ) / (n + 1) := by rw [integral_finsetSum _ (fun i _ => simplex_coordinate_integrable_local n i), Finset.mul_sum] exact Finset.sum_congr rfl (fun i _ => simplex_coordinate_first_moment n i) _ = ((j : ℕ) + 1 : ℝ) / (n + 1) := by simp [s, Fin.card_Iic, div_eq_mul_inv]
UniformTaggedRank 1 core · 7 supporting These facts isolate the finite-product and tie-free steps used by the tagged concomitant cell law. ★ uniform_tagged_rank_mass
Ranks and binomial counts in an iid uniform tuple
These facts isolate the finite-product and tie-free steps used by the tagged concomitant cell law. A tagged point's rank is the number of other observations below it, and that count at a fixed threshold has a binomial law.
A positive sample size, tagged coordinate, and rank have uniform rank mass under the iid unit-uniform law: the probability that the tagged observation occupies that position in the sorted sample is one over the sample size.
Formal statement
Proof (Lean source)
7 supporting declarations (lemmas, instances)
-
iid_uniform_coordinates_injective_aetheorem — For an iid unit-uniform tuple, its coordinates are pairwise distinct almost surely.Proof (Lean source)
theorem iid_uniform_coordinates_injective_ae {N : ℕ} : ∀ᵐ u ∂iidSample uniform01 N, Injective u := by rw [iid_uniform_cube_law] apply ae_restrict_of_ae have hpair (i j : Fin N) (hij : i ≠ j) : ∀ᵐ u : Fin N → ℝ ∂volume, u i ≠ u j := by let L : (Fin N → ℝ) →ₗ[ℝ] ℝ := (LinearMap.proj i : (Fin N → ℝ) →ₗ[ℝ] ℝ) - LinearMap.proj j have hL : L ≠ 0 := by intro h have h' := LinearMap.congr_fun h (fun k => if k = i then 1 else 0) simp [L, hij.symm] at h' have hker : LinearMap.ker L ≠ ⊤ := by intro h exact hL (LinearMap.ker_eq_top.mp h) have hs : {u : Fin N → ℝ | u i = u j} = (LinearMap.ker L : Set (Fin N → ℝ)) := by ext u simp [L, LinearMap.mem_ker, sub_eq_zero] apply (ae_iff).2 simp only [not_not] change volume {u : Fin N → ℝ | u i = u j} = 0 rw [hs] exact Measure.addHaar_submodule volume (LinearMap.ker L) hker have hall : ∀ᵐ u : Fin N → ℝ ∂volume, ∀ i j : Fin N, i ≠ j → u i ≠ u j := by simp only [Filter.eventually_all] intro i j hij exact hpair i j hij filter_upwards [hall] with u hu i j hij by_contra hne exact hu i j hne hij -
uniform_tagged_rank_eq_counttheorem — For an iid unit-uniform tuple with no ties, the zero-based rank of a tagged coordinate equals the number of other coordinates below it.hypothesesProof (Lean source)
theorem uniform_tagged_rank_eq_count {N : ℕ} (u : Fin N → ℝ) (i : Fin N) (hu : Injective u) : ((Tuple.sort u).symm i).val = (((Finset.univ : Finset (Fin N)).erase i).filter (fun k => u k < u i)).card := by let σ := Tuple.sort u have hs : StrictMono (u ∘ σ) := (Tuple.monotone_sort u).strictMono_of_injective (hu.comp σ.injective) have hcard : ((Finset.univ : Finset (Fin N)).filter (fun k => k < σ.symm i)).card = (σ.symm i).val := by simpa using (Fin.card_filter_val_lt (n := N) (m := (σ.symm i).val)) rw [← hcard] apply Finset.card_equiv σ intro k simp only [mem_filter, Finset.mem_univ, true_and, Finset.mem_erase, ne_eq, and_true] constructor · intro hk have : u (σ k) < u i := by simpa only [Function.comp_apply, σ.apply_symm_apply] using hs hk exact ⟨by intro h; subst h; exact (lt_irrefl _ this), this⟩ · intro hk apply hs.lt_iff_lt.mp simpa only [Function.comp_apply, σ.apply_symm_apply] using hk.2 -
uniform_subset_lt_count_masstheorem — For any finite set of coordinates in an iid unit-uniform tuple, the number strictly below a threshold in the unit interval has the binomial mass with one trial per selected coordinate.hypothesesProof (Lean source)
theorem uniform_subset_lt_count_mass {N : ℕ} (S : Finset (Fin N)) (r : ℕ) {v : ℝ} (hv : v ∈ Icc (0 : ℝ) 1) : iidSample uniform01 N {u | (S.filter (fun k => u k < v)).card = r} = ofReal ((Nat.choose S.card r : ℝ) * v ^ r * (1 - v) ^ (S.card - r)) := by let p : unitInterval := ⟨v, hv⟩ let f : Fin N → ℝ → Prop := fun k x => k ∈ S ∧ x < v haveI : IsProbabilityMeasure uniform01 := ⟨by simp [uniform01]⟩ have hbase : Measure.map (fun x : ℝ => x < v) uniform01 = unitInterval.toNNReal p • Measure.dirac True + unitInterval.toNNReal (unitInterval.symm p) • Measure.dirac False := by apply Measure.ext_of_singleton intro b by_cases hb : b · have he : b = True := propext (iff_true_intro hb) rw [he] rw [show (Measure.map (fun x : ℝ => x < v) uniform01) {True} = uniform01 (Iio v) by rw [Measure.map_apply (by fun_prop) (by simp)] congr 1 ext x simp] simp only [Measure.add_apply, Measure.smul_apply] simp rw [uniform01, Measure.restrict_apply measurableSet_Iio] have hs : Iio v ∩ Icc 0 1 = Ico 0 v := by ext x simp only [Set.mem_inter_iff, Set.mem_Iio, Set.mem_Icc, Set.mem_Ico] exact ⟨fun h => ⟨h.2.1, h.1⟩, fun h => ⟨h.2, h.1, le_trans h.2.le hv.2⟩⟩ rw [hs, Real.volume_Ico] simp only [sub_zero, ofReal, unitInterval.toNNReal] congr 1 exact Subtype.ext (Real.coe_toNNReal v hv.1) · have he : b = False := propext (iff_false_intro hb) rw [he] rw [show (Measure.map (fun x : ℝ => x < v) uniform01) {False} = uniform01 (Ici v) by rw [Measure.map_apply (by fun_prop) (by simp)] congr 1 ext x simp] simp only [Measure.add_apply, Measure.smul_apply] simp rw [uniform01, Measure.restrict_apply measurableSet_Ici] have hs : Ici v ∩ Icc 0 1 = Icc v 1 := by ext x simp only [Set.mem_inter_iff, Set.mem_Ici, Set.mem_Icc] exact ⟨fun h => ⟨h.1, h.2.2⟩, fun h => ⟨h.1, le_trans hv.1 h.1, h.2⟩⟩ rw [hs, Real.volume_Icc] simp only [ofReal, unitInterval.toNNReal] congr 1 exact Subtype.ext (Real.coe_toNNReal (1 - v) (sub_nonneg.mpr hv.2)) haveI (k : Fin N) : IsProbabilityMeasure (uniform01.map (f k)) := Measure.isProbabilityMeasure_map (by fun_prop) have hcoord (k : Fin N) : uniform01.map (f k) = unitInterval.toNNReal p • Measure.dirac (k ∈ (S : Set (Fin N))) + unitInterval.toNNReal (unitInterval.symm p) • Measure.dirac False := by by_cases hk : k ∈ S · simpa [f, p, hk] using hbase · simp [f, hk, ← add_smul, unitInterval.toNNReal_add_toNNReal_symm] have hLaw : (iidSample uniform01 N).map (fun u => {k | k ∈ S ∧ u k < v}) = ProbabilityTheory.setBernoulli (S : Set (Fin N)) p := by calc (iidSample uniform01 N).map (fun u => {k | k ∈ S ∧ u k < v}) = (Measure.pi fun k => uniform01.map (f k)).map (fun b => {k | b k}) := by rw [← Measure.pi_map_pi (fun k => (show AEMeasurable (f k) uniform01 from by fun_prop))] rw [Measure.map_map (by fun_prop) (by fun_prop)] rfl _ = ProbabilityTheory.setBernoulli (S : Set (Fin N)) p := by simp_rw [hcoord] rw [ProbabilityTheory.setBernoulli_eq_map, Measure.infinitePi_eq_pi] calc iidSample uniform01 N {u | (S.filter (fun k => u k < v)).card = r} = ((iidSample uniform01 N).map (fun u => {k | k ∈ S ∧ u k < v})).map ncard {r} := by rw [Measure.map_apply (by fun_prop) (by simp)] rw [Measure.map_apply (by fun_prop) (by measurability)] congr 1 ext u have he : {k | k ∈ S ∧ u k < v} = (S.filter (fun k => u k < v) : Set (Fin N)) := by ext k simp change (S.filter (fun k => u k < v)).card = r ↔ ({k | k ∈ S ∧ u k < v} : Set (Fin N)).ncard = r rw [he, Set.ncard_coe_finset] _ = (ProbabilityTheory.setBernoulli (S : Set (Fin N)) p).map ncard {r} := by rw [hLaw] _ = _ := by rw [ProbabilityTheory.map_ncard_setBernoulli_singleton (Set.toFinite (S : Set (Fin N)))] simp [p] -
iid_uniform_relabel_lawtheorem — Relabeling the coordinates of an iid unit-uniform tuple by a permutation preserves its finite-product probability law.hypothesesProof (Lean source)
theorem iid_uniform_relabel_law {N : ℕ} (σ : Perm (Fin N)) : (iidSample uniform01 N).map (fun u i => u (σ i)) = iidSample uniform01 N := by haveI : IsProbabilityMeasure uniform01 := ⟨by simp [uniform01]⟩ have hf : (fun u : Fin N → ℝ => fun i => u (σ i)) = (MeasurableEquiv.piCongrLeft (fun _ : Fin N => ℝ) σ.symm : (Fin N → ℝ) → (Fin N → ℝ)) := by funext u i simp [MeasurableEquiv.coe_piCongrLeft, Equiv.piCongrLeft_apply] rw [hf] simpa [iidSample] using Measure.pi_map_piCongrLeft σ.symm (fun _ : Fin N => uniform01) -
uniform_tagged_rank_mass_eq_of_tagtheorem — For an iid uniform tuple, two tagged coordinates have the same probability of occupying any specified rank.hypothesesN :ℕi k j :Fin NProof (Lean source)
theorem uniform_tagged_rank_mass_eq_of_tag {N : ℕ} (i k j : Fin N) : iidSample uniform01 N {u | (sort u).symm i = j} = iidSample uniform01 N {u | (sort u).symm k = j} := by classical let μ := iidSample uniform01 N let σ : Perm (Fin N) := Equiv.swap i k let R : (Fin N → ℝ) → Fin N → Prop := fun u a => (sort u).symm a = j have hmeas : NullMeasurableSet {u | R u i} μ := by let F : Set (Fin N → ℝ) := {u | (((Finset.univ : Finset (Fin N)).erase i).filter (fun a => u a < u i)).card = j.val} have hF : MeasurableSet F := by dsimp [F] apply measurableSet_eq_fun · simp_rw [Finset.card_filter] apply Finset.measurable_sum intro a _ apply Measurable.ite · exact measurableSet_lt (measurable_pi_apply a) (measurable_pi_apply i) · exact measurable_const · exact measurable_const · exact measurable_const apply hF.nullMeasurableSet.congr filter_upwards [iid_uniform_coordinates_injective_ae (N := N)] with u hu apply propext change (((Finset.univ : Finset (Fin N)).erase i).filter (fun a => u a < u i)).card = j.val ↔ ((sort u).symm i = j) rw [← uniform_tagged_rank_eq_count u i hu] exact Fin.ext_iff.symm have hsort (u : Fin N → ℝ) (hu : Injective u) : (sort (fun a => u (σ a))).symm i = (sort u).symm (σ i) := by have hs (a : Fin N) : σ (sort (fun a => u (σ a)) a) = sort u a := by apply hu exact congrFun (Tuple.comp_perm_comp_sort_eq_comp_sort (f := u) (σ := σ)) a apply (sort u).injective calc (sort u) ((sort (fun a => u (σ a))).symm i) = σ (sort (fun a => u (σ a)) ((sort (fun a => u (σ a))).symm i)) := (hs _).symm _ = σ i := by simp _ = (sort u) ((sort u).symm (σ i)) := by simp have hrelabel : Measurable (fun u : Fin N → ℝ => fun a => u (σ a)) := by fun_prop have hmeas' : NullMeasurableSet {u | R u i} (μ.map (fun u => fun a => u (σ a))) := by rw [iid_uniform_relabel_law σ] exact hmeas calc μ {u | R u i} = (μ.map (fun u => fun a => u (σ a))) {u | R u i} := by rw [iid_uniform_relabel_law σ] _ = μ {u | R (fun a => u (σ a)) i} := by rw [Measure.map_apply₀ hrelabel.aemeasurable hmeas'] rfl _ = μ {u | R u k} := by apply measure_congr filter_upwards [iid_uniform_coordinates_injective_ae (N := N)] with u hu apply propext change (sort (fun a => u (σ a))).symm i = j ↔ (sort u).symm k = j rw [hsort u hu] simp [σ] -
sum_uniform_tagged_rank_masstheorem — For one rank of an iid uniform tuple, the masses of the events that each possible tag occupies that rank sum to one.hypothesesN :ℕj :Fin NProof (Lean source)
theorem sum_uniform_tagged_rank_mass {N : ℕ} (j : Fin N) : (∑ i : Fin N, iidSample uniform01 N {u | (sort u).symm i = j}) = 1 := by classical let μ := iidSample uniform01 N let E : Fin N → Set (Fin N → ℝ) := fun i => {u | (sort u).symm i = j} have hmeas (i : Fin N) : NullMeasurableSet (E i) μ := by let F : Set (Fin N → ℝ) := {u | (((Finset.univ : Finset (Fin N)).erase i).filter (fun k => u k < u i)).card = j.val} have hF : MeasurableSet F := by dsimp [F] apply measurableSet_eq_fun · simp_rw [Finset.card_filter] apply Finset.measurable_sum intro k _ apply Measurable.ite · exact measurableSet_lt (measurable_pi_apply k) (measurable_pi_apply i) · exact measurable_const · exact measurable_const · exact measurable_const apply hF.nullMeasurableSet.congr filter_upwards [iid_uniform_coordinates_injective_ae (N := N)] with u hu apply propext change ( (((Finset.univ : Finset (Fin N)).erase i).filter (fun k => u k < u i)).card = j.val) ↔ ((sort u).symm i = j) rw [← uniform_tagged_rank_eq_count u i hu] exact Fin.ext_iff.symm have hdisj : Pairwise (onFun (AEDisjoint μ) E) := by intro i k hik apply Disjoint.aedisjoint rw [Set.disjoint_left] intro u hi hk have hi' : (sort u).symm i = j := hi have hk' : (sort u).symm k = j := hk exact hik ((sort u).symm.injective (hi'.trans hk'.symm)) have hcover : (⋃ i, E i) = univ := by ext u simp only [Set.mem_iUnion, Set.mem_univ, iff_true] exact ⟨(sort u) j, by simp [E]⟩ haveI : IsProbabilityMeasure μ := by haveI : IsProbabilityMeasure uniform01 := ⟨by simp [uniform01]⟩ dsimp [μ, iidSample] infer_instance calc (∑ i : Fin N, μ (E i)) = ∑' i : Fin N, μ (E i) := (tsum_fintype _).symm _ = μ (⋃ i, E i) := (measure_iUnion₀ hdisj hmeas).symm _ = 1 := by rw [hcover]; exact measure_univ -
uniform_other_lt_count_masstheorem — For a tagged coordinate of an iid unit-uniform tuple and a point inside the unit interval, the number of other coordinates below that point has the binomial mass with N-1 trials.hypothesesProof (Lean source)
theorem uniform_other_lt_count_mass {N : ℕ} (i j : Fin N) {v : ℝ} (hv : v ∈ Icc (0 : ℝ) 1) : iidSample uniform01 N {u | (((Finset.univ : Finset (Fin N)).erase i).filter (fun k => u k < v)).card = j.val} = ofReal ((choose (N - 1) j.val : ℝ) * v ^ j.val * (1 - v) ^ (N - 1 - j.val)) := by have hcard : ((Finset.univ : Finset (Fin N)).erase i).card = N - 1 := by simp simpa [hcard] using (uniform_subset_lt_count_mass ((Finset.univ : Finset (Fin N)).erase i) j.val hv)