@@ -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,83 @@ 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 expectation_sqr_eq0 (X : {RV P >-> R}) :
660+ 'E_P[X ^+ 2] = 0 -> ae_eq P setT (EFin \o X) (EFin \o cst 0%R).
661+ Proof .
662+ move => hx.
663+ have x20: ae_eq P setT (EFin \o (X ^+ 2)%R) (EFin \o cst 0%R).
664+ apply ae_eq_integral_abs => //; first by apply/EFin_measurable_fun.
665+ have -> : \int[P]_x `|(EFin \o (X ^+ 2)%R) x| = 'E_P[X ^+ 2] => //.
666+ under eq_integral => x _. rewrite gee0_abs. over.
667+ apply sqr_ge0.
668+ reflexivity.
669+ apply: (ae_imply _ x20) => x /=.
670+ rewrite -expr2 => h0 _.
671+ apply EFin_inj in h0 => //.
672+ have: (X ^+ 2)%R x == 0%R. rewrite -h0 //.
673+ rewrite sqrf_eq0 /= => h1.
674+ rewrite (eqP h1) //.
675+ Qed .
676+
677+ Lemma cauchy_schwarz (X Y : {RV P >-> R}) :
678+ P.-integrable [set: T] (EFin \o X) -> P.-integrable [set: T] (EFin \o Y) ->
679+ (* 'E X < +oo -> 'E Y < +oo -> TODO: use lspaces *)
680+ 'E_P[(X \* Y)%R] ^+2 <= 'E_P[(X ^+ 2)%R] + 'E_P[(Y ^+ 2)%R].
681+ Proof .
682+ move => hfinex hfiney.
683+ pose a := Num.sqrt (fine 'E_P[(Y ^+ 2)%R]).
684+ pose b := Num.sqrt (fine 'E_P[(X ^+ 2)%R]).
685+ have ex2_ge0 : 0 <= 'E_P[(X ^+ 2)%R] by apply expectation_ge0 => x /=; exact: sqr_ge0.
686+ have ey2_ge0 : 0 <= 'E_P[(Y ^+ 2)%R] by apply expectation_ge0 => x /=; exact: sqr_ge0.
687+ have [a0|a0] := eqVneq ('E_P[(Y ^+ 2)%R]) 0.
688+ - rewrite a0 adde0.
689+ have y0: ae_eq P setT (EFin \o Y) (EFin \o cst 0%R) by apply expectation_sqr_eq0.
690+ have -> : 'E_P[X \* Y] = 'E_P[cst 0%R].
691+ apply: ae_eq_integral => //=.
692+ apply measurable_funT_comp => //; apply measurable_funM => //.
693+ apply measurable_fun_cst.
694+ apply: (ae_imply _ y0) => x /= h _.
695+ apply EFin_inj in h => //.
696+ by rewrite h mulr0.
697+ rewrite expectation_cst /= mule0.
698+ apply expectation_ge0 => x.
699+ apply sqr_ge0.
700+ have [b0|b0] := eqVneq ('E_P[(X ^+ 2)%R]) 0.
701+ - rewrite b0 add0e.
702+ have x0: ae_eq P setT (EFin \o X) (EFin \o cst 0%R) by apply expectation_sqr_eq0.
703+ have -> : 'E_P[X \* Y] = 'E_P[cst 0%R].
704+ apply: ae_eq_integral => //=.
705+ apply measurable_funT_comp => //; apply measurable_funM => //.
706+ apply measurable_fun_cst.
707+ apply: (ae_imply _ x0) => x /= h _.
708+ apply EFin_inj in h => //.
709+ by rewrite h mul0r.
710+ rewrite expectation_cst /= mule0.
711+ apply expectation_ge0 => x.
712+ apply sqr_ge0.
713+ have H2ab : (2 * a * b * (b * a) = a * a * (fine 'E_P[X ^+ 2]) + b * b * (fine 'E_P[Y ^+ 2]))%R.
714+ rewrite -(sqr_sqrtr (a:=fine 'E_P[X ^+ 2])); last (apply: fine_ge0; apply: expectation_ge0 => x; apply sqr_ge0).
715+ rewrite -(sqr_sqrtr (a:=fine 'E_P[Y ^+ 2])); last (apply: fine_ge0; apply: expectation_ge0 => x; apply sqr_ge0).
716+ rewrite -/a -/b /GRing.exp /=.
717+ by rewrite mulrA (mulrC (_ * _) a)%R ![in LHS]mulrA (mulrC a) (mulrC _ (a * a)%R)
718+ -![in LHS]mulrA mulrC mulr2n !mulrA mulrDr mulr1.
719+ Admitted .
720+
721+ Lemma cauchy_schwarz' (X Y : {RV P >-> R}) :
722+ ('Cov[ X , Y ])^+2 <= 'V_P[X] + 'V_P[Y].
723+ Proof .
724+ rewrite /variance /covariance.
725+ apply cauchy_schwarz.
726+ Admitted .
727+
728+ End covariance.
729+ Notation "''Cov' [ X , Y ]" := (covariance X Y).
0 commit comments