Module mathcomp.analysis.probability_theory.normal_distribution
From HB Require Import structures.From mathcomp Require Import all_ssreflect_compat ssralg ssrnum ssrint interval.
From mathcomp Require Import archimedean finmap interval_inference.
From mathcomp Require Import boolp classical_sets functions cardinality fsbigop.
From mathcomp Require Import reals ereal topology normedtype sequences derive.
From mathcomp Require Import measure exp trigo numfun realfun.
From mathcomp Require Import measurable_realfun lebesgue_measure.
From mathcomp Require Import lebesgue_integral ftc gauss_integral.
Set SsrOldRewriteGoalsOrder.
Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
Import Order.TTheory GRing.Theory Num.Def Num.Theory.
Import numFieldTopology.Exports.
Local Open Scope classical_set_scope.
Local Open Scope ring_scope.
Section normal_density.
Context { : realType}.
Local Open Scope ring_scope.
Local Import Num.ExtraDef.
Implicit Types m s x : R.
Definition
Source code
Lemma
Source code
Proof.
apply: measurableT_comp => //=; apply: measurable_funX => //=.
exact: measurable_funB.
Qed.
Lemma
Source code
Proof.
Lemma
Source code
Proof.
Definition
normal_fun : forall {R : realType}, R -> R -> R -> R normal_fun is not universe polymorphic Arguments normal_fun {R} (m s x)%ring_scope normal_fun is transparent Expands to: Constant mathcomp.analysis.probability_theory.normal_distribution.normal_fun Declared in library mathcomp.analysis.probability_theory.normal_distribution, line 42, characters 11-21
Source code
Lemma
Source code
Proof.
Lemma
Source code
Proof.
by rewrite mulrn_wgt0// mulr_gt0 ?pi_gt0// exprn_even_gt0/=.
Qed.
Let
Source code
Definition
normal_peak : forall {R : realType}, R -> join_Num_NumDomain_between_Order_Preorder_and_GRing_UnitRing R normal_peak is not universe polymorphic Arguments normal_peak {R} s%ring_scope normal_peak is transparent Expands to: Constant mathcomp.analysis.probability_theory.normal_distribution.normal_peak Declared in library mathcomp.analysis.probability_theory.normal_distribution, line 57, characters 11-22
Source code
if s == 0 then \1_`[0, 1] x else normal_pdf0 m s x.
Lemma
Source code
Proof.
Let
Source code
Proof.
Let
Source code
Proof.
Let
Source code
Proof.
Let
Source code
Proof.
Lemma
Source code
Proof.
Let
Source code
Proof.
Let
Source code
Proof.
rewrite -[leRHS]expR0 ler_expR mulNr oppr_le0 mulr_ge0// ?sqr_ge0//.
by rewrite invr_ge0 mulrn_wge0// sqr_ge0.
Qed.
Lemma
Source code
Proof.
Lemma
Source code
Proof.
Lemma
Source code
Proof.
End normal_density.
Definition
normal_pdf : forall {R : realType}, R -> R -> R -> R normal_pdf is not universe polymorphic Arguments normal_pdf {R} (m s x)%ring_scope normal_pdf is transparent Expands to: Constant mathcomp.analysis.probability_theory.normal_distribution.normal_pdf Declared in library mathcomp.analysis.probability_theory.normal_distribution, line 69, characters 11-21
Source code
fun => (\int[lebesgue_measure]_( in V) (normal_pdf m s x)%:E)%E.
Section normal_probability.
Variables ( : realType) (
Source code
Local Open Scope ring_scope.
Notation := lebesgue_measure.
Local Notation
Source code
Local Notation
Source code
Let ( : R^o) := (x - m) / (Num.sqrt (sigma ^+ 2 *+ 2)).
Let
Source code
Proof.
Let
Source code
Proof.
Let
Source code
(\int[mu]_ ((((gauss_fun \o F) *
(F^`())%classic) x)%:E * (Num.sqrt (sigma ^+ 2 *+ 2))%:E))%E =
normal_peak^-1%:E.
Proof.
rewrite -mulrnAr -[in RHS]mulr_natr sqrtrM ?(sqrtrM 2) ?sqr_ge0 ?pi_ge0// !EFinM.
rewrite muleCA ge0_integralZr//=; first last.
by move=> x _; rewrite lee_fin mulr_ge0//= ?gauss_fun_ge0// F'E/= invr_ge0.
rewrite F'E; apply/measurable_EFinP/measurable_funM => //.
apply/measurableT_comp => //; first exact: measurable_gauss_fun.
by apply: measurable_funM => //; exact: measurable_funD.
congr *%E; last by rewrite -(mulr_natr (_ ^+ 2)) sqrtrM ?sqr_ge0.
rewrite -increasing_ge0_integration_by_substitutionT//.
- exact: integralT_gauss.
- move=> x y xy; rewrite /F ltr_pM2r ?ltr_leB ?gt_eqF//.
by rewrite invr_gt0 ?sqrtr_gt0 ?pmulrn_lgt0 ?exprn_even_gt0.
- by rewrite F'E => ?; exact: cvg_cst.
- by rewrite F'E; exact: is_cvg_cst.
- by rewrite F'E; exact: is_cvg_cst.
- apply/gt0_cvgMlNy; last exact: cvg_addrr_Ny.
by rewrite invr_gt0// sqrtr_gt0 -mulr_natr mulr_gt0// exprn_even_gt0.
- apply/gt0_cvgMly; last exact: cvg_addrr.
by rewrite invr_gt0// sqrtr_gt0 -mulr_natr mulr_gt0// exprn_even_gt0.
- exact: continuous_gauss_fun.
- by move=> x; rewrite gauss_fun_ge0.
Qed.
Let
Source code
(\int[mu]_ (normal_fun x)%:E)%E = normal_peak^-1%:E.
Proof.
rewrite F'E !fctE/= -EFinM divfK// ?normal_gauss_fun//.
by rewrite gt_eqF// sqrtr_gt0 pmulrn_lgt0// exprn_even_gt0.
Qed.
Let
Source code
mu.-integrable [set: R] (EFin \o normal_fun).
Proof.
by apply/measurable_EFinP; exact: measurable_normal_fun.
under eq_integral do rewrite /= ger0_norm ?expR_ge0//.
by rewrite /= integral_normal_fun// ltry.
Qed.
Lemma
Source code
Proof.
by rewrite integral_indic//= setIT lebesgue_measure_itv/= lte01 oppr0 adde0.
under eq_integral do rewrite EFinM.
rewrite integralZl//=; last exact: integrable_normal_fun.
by rewrite integral_normal_fun// -EFinM divff// gt_eqF// normal_peak_gt0.
Qed.
Lemma
Source code
(fun => (normal_pdf m sigma x)%:E).
Proof.
by apply/measurable_EFinP; exact: measurable_normal_pdf.
apply/abse_integralP => //=; last by rewrite integral_normal_pdf abse1 ltry.
by apply/measurable_EFinP; exact: measurable_normal_pdf.
Qed.
Local Notation
Source code
Local Notation
Source code
Let
Source code
Proof.
Let
Source code
Proof.
Let
Source code
Proof.
rewrite /normal_prob/= integral_bigcup//=; last first.
by apply: (integrableS _ _ (subsetT _)) => //; exact: integrable_normal_pdf.
apply: is_cvg_ereal_nneg_natsum_cond => n _ _.
by apply: integral_ge0 => /= x ?; rewrite lee_fin normal_pdf_ge0 ?ltW.
Qed.
.
Source code
Source code
Source code
normal_prob normal0 normal_ge0 normal_sigma_additive.
Let
Source code
Proof.
.
Source code
Source code
Source code
Lemma
Source code
Proof.
have [s0|s0] := eqVneq sigma 0.
apply: null_set_integral => //=; apply: measurable_funTS => /=.
exact/measurable_EFinP/measurable_indic.
apply/eqP; rewrite eq_le; apply/andP; split; last first.
apply: integral_ge0 => x _.
by rewrite lee_fin mulr_ge0 ?normal_peak_ge0 ?normal_fun_ge0.
apply: (@le_trans _ _ (\int[mu]_( in A) (normal_peak)%:E))%E; last first.
by rewrite integral_cst//= muA0 mule0.
apply: ge0_le_integral => //=.
- by move=> x _; rewrite lee_fin mulr_ge0 ?normal_peak_ge0 ?normal_fun_ge0.
- apply/measurable_funTS/measurableT_comp => //=.
by apply: measurable_funM => //; exact: measurable_normal_fun.
- by move=> x _; have := normal_pdf_ub m x s0; rewrite /normal_pdf (negbTE s0).
Qed.
End normal_probability.