Skip to content

Commit 134bbe0

Browse files
committed
start working on Cauchy-Schwarz
1 parent 673a468 commit 134bbe0

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

theories/probability.v

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,51 @@ Qed.
306306
End variance.
307307
Notation "''V' X" := (variance X).
308308

309+
Section covariance.
310+
Local Open Scope ereal_scope.
311+
Variables (d : _) (T : measurableType d) (R : realType) (P : probability T R).
312+
313+
Definition covariance (X Y : {RV P >-> R}) :=
314+
'E ((X `- cst_mfun (fine 'E X)) `* (Y `- cst_mfun (fine 'E Y))).
315+
Local Notation "''Cov' [ X , Y ]" := (covariance X Y).
316+
317+
Lemma cauchy_schwarz (X Y : {RV P >-> R}) :
318+
'E X < +oo -> 'E Y < +oo ->
319+
'E (X `* Y) ^+2 <= 'E (X`^+2) + 'E (Y`^+2).
320+
Proof.
321+
move => hfinex hfiney.
322+
pose a := Num.sqrt (fine 'E (Y`^+2)).
323+
pose b := Num.sqrt (fine 'E (X`^+2)).
324+
have ex2_ge0 : 0 <= 'E (X `^+ 2) by apply expectation_ge0 => x /=; rewrite /mexp; exact: sqr_ge0.
325+
have ey2_ge0 : 0 <= 'E (Y `^+ 2) by apply expectation_ge0 => x /=; rewrite /mexp; exact: sqr_ge0.
326+
have [a0|a0] := eqVneq ('E (Y`^+2)) 0.
327+
rewrite a0 adde0.
328+
have -> : 'E (X `* Y) = 0. admit.
329+
rewrite /= mule0.
330+
apply ex2_ge0.
331+
have [b0|b0] := eqVneq ('E (X`^+2)) 0.
332+
rewrite b0 add0e.
333+
have -> : 'E (X `* Y) = 0. admit.
334+
rewrite /= mule0.
335+
apply ey2_ge0.
336+
have H2ab : (2 * a * b * (b * a) = a * a * (fine 'E (X`^+2)) + b * b * (fine 'E (Y`^+2)))%R.
337+
rewrite -(sqr_sqrtr (a:=fine 'E (X`^+2))); last (apply: fine_ge0; apply: expectation_ge0 => x; apply sqr_ge0).
338+
rewrite -(sqr_sqrtr (a:=fine 'E (Y`^+2))); last (apply: fine_ge0; apply: expectation_ge0 => x; apply sqr_ge0).
339+
rewrite -/a -/b /GRing.exp /=.
340+
by rewrite mulrA (mulrC (_ * _) a)%R ![in LHS]mulrA (mulrC a) (mulrC _ (a * a)%R)
341+
-![in LHS]mulrA mulrC mulr2n !mulrA mulrDr mulr1.
342+
Admitted.
343+
344+
Lemma cauchy_schwarz' (X Y : {RV P >-> R}) :
345+
('Cov[ X , Y ])^+2 <= 'V X + 'V Y.
346+
Proof.
347+
rewrite /variance /covariance.
348+
apply cauchy_schwarz.
349+
Admitted.
350+
351+
End covariance.
352+
Notation "''Cov' [ X , Y ]" := (covariance X Y).
353+
309354
Section distribution.
310355
Variables (d : _) (T : measurableType d) (R : realType) (P : probability T R)
311356
(X : {mfun T >-> R}).

0 commit comments

Comments
 (0)