@@ -213,36 +213,47 @@ split.
213213 exact: measurable_funT_comp.
214214 + by move=> t _/=; rewrite lee_fin normrX.
215215Qed .
216-
217216End Lspace.
218- Notation "`|| f ||_ p" := (Lp_norm p f) (at level 0).
219217
220218Section Lspace.
221219Context d (T : measurableType d) (R : realType).
222220Variable mu : {finite_measure set T -> \bar R}.
223221
224- Notation "`|| f ||_ p" := (Lp_norm mu p f) (at level 0).
222+ Lemma powere12_sqrt (a : \bar R) : (0 <= a)%E -> (a `^ (2^-1))%E = sqrte a.
223+ Admitted .
224+
225+ Definition Lp_norm (p : nat) (f : T -> R) : \bar R :=
226+ ((\int[mu]_x (`|f x| ^+ p)%:E) `^ (p%:R^-1))%E.
227+
228+ Local Notation "`|| f ||_ p" := (Lp_norm p f) (at level 0).
229+
230+ Lemma hoelder (f g : T -> R) p q :
231+ measurable_fun setT f -> measurable_fun setT g -> (p%:R^-1 + q%:R^-1 = 1 :> R) ->
232+ (`|| (f \* g)%R ||_1 <= `|| f ||_p * `|| g ||_q)%E.
233+ Admitted .
234+ (* follow http://pi.math.cornell.edu/~erin/analysis/lectures.pdf version with convexity, not young inequality *)
225235
226236(* FROM https://ocw.mit.edu/courses/18-125-measure-and-integration-fall-2003/6f21af6c40de1eccd70349bd3a3b0095_18125_lec17.pdf *)
227- Lemma Lspace2_Lspace1 :
228- Lspace mu 2 `<=` Lspace mu 1.
237+ Lemma Lspace2_Lspace1 (f : Ltype mu 2%N) : mu.-integrable [set: T] (EFin \o repr f).
229238Proof .
230- move => f [mf foo]; split => //.
239+ have mf := Lfun.mf (repr f).
240+ have foo := Lfun.intf (repr f).
241+ split; [exact/EFin_measurable_fun|].
231242apply: (@le_lt_trans _ _
232- (sqrte (\int[mu]_x (`|f x| ^+ 2)%:E) * sqrte (mu setT)))%E; last first.
243+ (sqrte (\int[mu]_x (`|repr f x| ^+ 2)%:E) * sqrte (mu setT)))%E; last first.
233244 rewrite muleC lte_mul_pinfty//.
234245 + by rewrite esqrt_ge0.
235246 + by rewrite fin_num_esqrt// fin_num_measure.
236247 + by rewrite -ge0_fin_numE ?esqrt_ge0// fin_num_esqrt// ge0_fin_numE// integral_ge0//.
237248rewrite -[X in (_ * sqrte (mu X))%E](setTI setT).
238249rewrite -integral_indic//.
239250under [X in (_ * sqrte X)%E]eq_integral. move => x _. rewrite indicT. rewrite -(@ger0_norm _ (cst 1 x) _) //=. over.
240- rewrite -expe12_sqrt ; last by apply: integral_ge0.
241- rewrite -expe12_sqrt ; last by apply: integral_ge0.
251+ rewrite -powere12_sqrt ; last by apply: integral_ge0.
252+ rewrite -powere12_sqrt ; last by apply: integral_ge0.
242253rewrite (_ : (\int[mu]__ `|1|%:E)%E = (\int[mu]_x `|cst 1 x| ^+ 2)%E); last first.
243254 by apply: eq_integral => t _ /=; rewrite normr1 mule1.
244255have : 2^-1 + 2^-1 = 1 :> R by rewrite -div1r -splitr.
245- move/(@hoelder _ _ _ mu _ (cst 1%R) _ _ mf (measurable_fun_cst _)).
256+ move/(@hoelder _ (cst 1%R) _ _ mf (measurable_fun_cst _)).
246257rewrite /Lp_norm.
247258apply: le_trans.
248259rewrite /Lp_norm /=.
@@ -271,79 +282,10 @@ Lemma probability_range d (T : measurableType d) (R : realType)
271282 (P : probability T R) (X : {RV P >-> R}) : P (X @^-1` range X) = 1%E.
272283Proof . by rewrite preimage_range probability_setT. Qed .
273284
274- Section tmp.
275- Context d (T : measurableType d) (R : realType) (mu : {measure set T -> \bar R}).
276- Lemma integral_ae_eq (g f : T -> \bar R) :
277- mu.-integrable setT f -> mu.-integrable setT g ->
278- (forall E, measurable E -> \int[mu]_(x in E) f x = \int[mu]_(x in E) g x)%E ->
279- ae_eq mu setT f g.
280- Admitted .
281- End tmp.
282-
283- Section covariance.
284- Local Open Scope ereal_scope.
285- Variables (d : _) (T : measurableType d) (R : realType) (P : probability T R).
286-
287- Definition covariance (X Y : {RV P >-> R}) :=
288- ('E_P [(X \- cst (fine 'E_P[X])) \* (Y \- cst (fine 'E_P[Y]))])%R.
289- Local Notation "''Cov' [ X , Y ]" := (covariance X Y).
290-
291- Lemma square_X_0_ae (X : {RV P >-> R}) :
292- P.-Lspace 2 X -> 'E_P[(X ^+ 2)%R] = 0 -> ae_eq P setT (EFin \o X) (EFin \o cst 0%R).
293- Proof .
294- move => l2x xsqr0.
295- apply integral_ae_eq => /=.
296- Admitted .
297-
298- Lemma cauchy_schwarz (X Y : {RV P >-> R}) :
299- P.-Lspace 1 X -> P.-Lspace 1 Y ->
300- (* 'E X < +oo -> 'E Y < +oo -> TODO: use lspaces *)
301- 'E_P[(X \* Y)%R] ^+2 <= 'E_P[(X ^+ 2)%R] + 'E_P[(Y ^+ 2)%R].
302- Proof .
303- move => hfinex hfiney.
304- pose a := Num.sqrt (fine 'E_P[(Y ^+ 2)%R]).
305- pose b := Num.sqrt (fine 'E_P[(X ^+ 2)%R]).
306- have ex2_ge0 : 0 <= 'E_P[(X ^+ 2)%R] by apply expectation_ge0 => x /=; rewrite /mexp; exact: sqr_ge0.
307- have ey2_ge0 : 0 <= 'E_P[(Y ^+ 2)%R] by apply expectation_ge0 => x /=; rewrite /mexp; exact: sqr_ge0.
308- have [a0|a0] := eqVneq ('E_P[(Y ^+ 2)%R]) 0.
309- - have: ae_eq P setT (EFin \o X) (EFin \o cst 0%R).
310- apply square_X_0_ae.
311- (* Here *)
312- Check (Lspace2_Lspace1).
313- rewrite a0 adde0.
314- have -> : 'E_P[(X \* Y)%R] = 0. admit.
315- rewrite /= mule0.
316- apply ex2_ge0.have [b0|b0] := eqVneq ('E (X`^+2)) 0.
317- rewrite b0 add0e.
318- have -> : 'E (X `* Y) = 0. admit.
319- rewrite /= mule0.
320- apply ey2_ge0.
321- have H2ab : (2 * a * b * (b * a) = a * a * (fine 'E (X`^+2)) + b * b * (fine 'E (Y`^+2)))%R.
322- rewrite -(sqr_sqrtr (a:=fine 'E (X`^+2))); last (apply: fine_ge0; apply: expectation_ge0 => x; apply sqr_ge0).
323- rewrite -(sqr_sqrtr (a:=fine 'E (Y`^+2))); last (apply: fine_ge0; apply: expectation_ge0 => x; apply sqr_ge0).
324- rewrite -/a -/b /GRing.exp /=.
325- by rewrite mulrA (mulrC (_ * _) a)%R ![in LHS]mulrA (mulrC a) (mulrC _ (a * a)%R)
326- -![in LHS]mulrA mulrC mulr2n !mulrA mulrDr mulr1.
327- Admitted .
328-
329- Lemma cauchy_schwarz' (X Y : {RV P >-> R}) :
330- ('Cov[ X , Y ])^+2 <= 'V X + 'V Y.
331- Proof .
332- rewrite /variance /covariance.
333- apply cauchy_schwarz.
334- Admitted .
335-
336- End covariance.
337- Notation "''Cov' [ X , Y ]" := (covariance X Y).
338-
339285Definition distribution (d : _) (T : measurableType d) (R : realType)
340286 (P : probability T R) (X : {mfun T >-> R}) :=
341287 pushforward P (@measurable_funP _ _ _ X).
342288
343- Section distribution.
344- Variables (d : _) (T : measurableType d) (R : realType) (P : probability T R)
345- (X : {mfun T >-> R}).
346-
347289Section distribution_is_probability.
348290Context d (T : measurableType d) (R : realType) (P : probability T R)
349291 (X : {mfun T >-> R}).
544486
545487End markov_chebyshev.
546488
489+
547490HB.mixin Record MeasurableFun_isDiscrete d (T : measurableType d) (R : realType)
548491 (X : T -> R) of @MeasurableFun d T R X := {
549492 countable_range : countable (range X)
@@ -704,3 +647,89 @@ Qed.
704647Local Close Scope ereal_scope.
705648
706649End discrete_distribution.
650+
651+ Section covariance.
652+ Local Open Scope ereal_scope.
653+ Variables (d : _) (T : measurableType d) (R : realType) (P : probability T R).
654+
655+ Definition covariance (X Y : {RV P >-> R}) :=
656+ ('E_P [(X \- cst (fine 'E_P[X])) \* (Y \- cst (fine 'E_P[Y]))])%R.
657+ Local Notation "''Cov' [ X , Y ]" := (covariance X Y).
658+
659+ Lemma cauchy_schwarz (X Y : {RV P >-> R}) :
660+ P.-integrable [set: T] (EFin \o X) -> P.-integrable [set: T] (EFin \o Y) ->
661+ (* 'E X < +oo -> 'E Y < +oo -> TODO: use lspaces *)
662+ 'E_P[(X \* Y)%R] ^+2 <= 'E_P[(X ^+ 2)%R] + 'E_P[(Y ^+ 2)%R].
663+ Proof .
664+ move => hfinex hfiney.
665+ pose a := Num.sqrt (fine 'E_P[(Y ^+ 2)%R]).
666+ pose b := Num.sqrt (fine 'E_P[(X ^+ 2)%R]).
667+ have ex2_ge0 : 0 <= 'E_P[(X ^+ 2)%R] by apply expectation_ge0 => x /=; exact: sqr_ge0.
668+ have ey2_ge0 : 0 <= 'E_P[(Y ^+ 2)%R] by apply expectation_ge0 => x /=; exact: sqr_ge0.
669+ have [a0|a0] := eqVneq ('E_P[(Y ^+ 2)%R]) 0.
670+ - rewrite a0 adde0.
671+ have y20: ae_eq P setT (EFin \o (Y ^+ 2)%R) (EFin \o cst 0%R).
672+ apply ae_eq_integral_abs => //.
673+ by apply/EFin_measurable_fun.
674+ have -> : \int[P]_x `|(EFin \o (Y ^+ 2)%R) x| = 'E_P[Y ^+ 2] => //.
675+ under eq_integral => x _. rewrite gee0_abs. over.
676+ simpl.
677+ apply sqr_ge0.
678+ reflexivity.
679+ have y0: ae_eq P setT (EFin \o Y) (EFin \o cst 0%R).
680+ apply: (ae_imply _ y20).
681+ move => x /=.
682+ rewrite -expr2 => h0.
683+ apply EFin_inj in h0 => //.
684+ have: (Y ^+ 2)%R x == 0%R. rewrite -h0 //.
685+ rewrite sqrf_eq0 /= => h1.
686+ rewrite (eqP h1) //.
687+ have -> : 'E_P[X \* Y] = 'E_P[cst 0%R].
688+ apply: ae_eq_integral => //=.
689+ apply measurable_funT_comp => //.
690+ apply measurable_funM => //.
691+ apply measurable_fun_cst.
692+ apply: (ae_imply _ y0) => x /= h _.
693+ apply EFin_inj in h => //.
694+ by rewrite h mulr0.
695+ rewrite expectation_cst /= mule0.
696+ apply expectation_ge0 => x.
697+ apply sqr_ge0.
698+ have [b0|b0] := eqVneq ('E_P[(X ^+ 2)%R]) 0.
699+ - rewrite b0 add0e.
700+ have x20: ae_eq P setT (EFin \o (X ^+ 2)%R) (EFin \o cst 0%R).
701+ apply ae_eq_integral_abs => //.
702+ by apply/EFin_measurable_fun.
703+ admit.
704+ have x0: ae_eq P setT (EFin \o X) (EFin \o cst 0%R).
705+ apply: (ae_imply _ x20).
706+ move => x /=.
707+ rewrite -expr2 => h0 _.
708+ admit.
709+ have -> : 'E_P[X \* Y] = 'E_P[cst 0%R].
710+ apply: ae_eq_integral => //=.
711+ admit.
712+ apply measurable_fun_cst.
713+ apply: (ae_imply _ x0) => x /= h _.
714+ apply EFin_inj in h => //.
715+ by rewrite h mul0r.
716+ rewrite expectation_cst /= mule0.
717+ apply expectation_ge0 => x.
718+ apply sqr_ge0.
719+ have H2ab : (2 * a * b * (b * a) = a * a * (fine 'E_P[X ^+ 2]) + b * b * (fine 'E_P[Y ^+ 2]))%R.
720+ rewrite -(sqr_sqrtr (a:=fine 'E_P[X ^+ 2])); last (apply: fine_ge0; apply: expectation_ge0 => x; apply sqr_ge0).
721+ rewrite -(sqr_sqrtr (a:=fine 'E_P[Y ^+ 2])); last (apply: fine_ge0; apply: expectation_ge0 => x; apply sqr_ge0).
722+ rewrite -/a -/b /GRing.exp /=.
723+ by rewrite mulrA (mulrC (_ * _) a)%R ![in LHS]mulrA (mulrC a) (mulrC _ (a * a)%R)
724+ -![in LHS]mulrA mulrC mulr2n !mulrA mulrDr mulr1.
725+ Admitted .
726+
727+ Lemma cauchy_schwarz' (X Y : {RV P >-> R}) :
728+ ('Cov[ X , Y ])^+2 <= 'V_P[X] + 'V_P[Y].
729+ Proof .
730+ rewrite /variance /covariance.
731+ apply cauchy_schwarz.
732+ Admitted .
733+
734+ End covariance.
735+ Notation "''Cov' [ X , Y ]" := (covariance X Y).
0 commit comments