Documentation

LeanMDPs.Finprob

structure Findist {τ : Type} (Ω : Finset τ) :

Finite probability distribution

  • p : τNNReal
  • sumsto : ωΩ, self.p ω = 1
Instances For
    @[reducible, inline]
    abbrev Delta {τ : Type} :
    Finset τType
    Equations
    Instances For
      @[reducible, inline]
      abbrev Δ {τ : Type} :
      Finset τType
      Equations
      Instances For
        structure Finprob (τ : Type) :

        Finite probability space

        Instances For
          structure Finrv {τ : Type} (P : Finprob τ) (ρ : Type) :

          Random variable defined on a finite probability space

          • val : τρ
          Instances For
            @[reducible]
            def Finprob.p {τ : Type} (P : Finprob τ) (ω : τ) :

            Probability measure

            Equations
            • P.p ω = P.prob.p ω
            Instances For
              noncomputable def Finprob.filter_zero {τ : Type} (P : Finprob τ) :

              Removes elements of Ω that have zero probability

              Equations
              • P.filter_zero = { Ω := Finset.filter (fun (ω : τ) => P.p ω 0) P, prob := { p := P.prob.p, sumsto := } }
              Instances For
                theorem prob_filtered_positive {τ : Type} {P Q : Finprob τ} (flrtd : Q = P.filter_zero) (ω : τ) :
                ω QQ.p ω > 0
                noncomputable def Finrv.filter_zero {τ : Type} {P : Finprob τ} {ε : Type} (X : Finrv P ε) :
                Finrv P.filter_zero ε
                Equations
                • X.filter_zero = { val := X.val }
                Instances For
                  def Finprob.supp {τ : Type} (P : Finprob τ) (ω : τ) :
                  Equations
                  • P.supp ω = (0 < P.p ω)
                  Instances For
                    @[reducible]

                    Boolean indicator function

                    Equations
                    Instances For
                      @[reducible, inline]
                      Equations
                      Instances For
                        theorem Finprob.ind_zero_one {τ : Type} (cond : τBool) (ω : τ) :
                        (Finprob.𝕀 cond) ω = 1 (Finprob.𝕀 cond) ω = 0

                        Indicator is 0 or 1

                        theorem Finprob.ind_ge_zero {τ : Type} (cond : τBool) (ω : τ) :
                        0 (Finprob.𝕀 cond) ω
                        def Finprob.expect {τ : Type} {P : Finprob τ} (X : Finrv P ) :

                        Expectation of X

                        Equations
                        • 𝔼[X] = ωP, (P.p ω) * X.val ω
                        Instances For
                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For
                            theorem Finprob.exp_ge_zero {τ : Type} {P : Finprob τ} {X : Finrv P } (gezero : ωP, 0 X.val ω) :
                            def Finprob.probability {τ : Type} {P : Finprob τ} (B : Finrv P Bool) :

                            Probability of B

                            Equations
                            Instances For
                              Equations
                              • One or more equations did not get rendered due to their size.
                              Instances For
                                @[reducible]
                                noncomputable def Finprob.expect_cnd {τ : Type} {P : Finprob τ} (X : Finrv P ) (B : Finrv P Bool) :

                                Expected value 𝔼[X|B] conditional on a Bool random variable IMPORTANT: conditional expectation for zero probability B is zero

                                Equations
                                Instances For
                                  Equations
                                  • One or more equations did not get rendered due to their size.
                                  Instances For
                                    theorem Finprob.exp_cnd_ge_zero {τ : Type} {P : Finprob τ} {X : Finrv P } {B : Finrv P Bool} (gezero : ωP, 0 X.val ω) :
                                    @[reducible]
                                    noncomputable def Finprob.probability_cnd {τ : Type} {P : Finprob τ} (B C : Finrv P Bool) :

                                    Conditional probability of B

                                    Equations
                                    Instances For
                                      Equations
                                      • One or more equations did not get rendered due to their size.
                                      Instances For
                                        @[reducible]
                                        def Finprob.EqRV {τ : Type} {P : Finprob τ} {η : Type} [DecidableEq η] (Y : Finrv P η) (y : η) :

                                        Random variable equality

                                        Equations
                                        • (Y ᵣ== y) = { val := fun (ω : τ) => Y.val ω == y }
                                        Instances For
                                          @[reducible]
                                          def Finprob.AndRV {τ : Type} {P : Finprob τ} (B C : Finrv P Bool) :
                                          Equations
                                          • (B ∧ᵣ C) = { val := fun (ω : τ) => B.val ω && C.val ω }
                                          Instances For
                                            @[reducible]
                                            def Finprob.OrRV {τ : Type} {P : Finprob τ} (B C : Finrv P Bool) :
                                            Equations
                                            • (B ∨ᵣ C) = { val := fun (ω : τ) => B.val ω || C.val ω }
                                            Instances For
                                              @[reducible]
                                              noncomputable def Finprob.expect_cnd_rv {τ : Type} {P : Finprob τ} {ν : Type} [DecidableEq ν] {V : Finset ν} (X : Finrv P ) (Y : Finrv P { x : ν // x V }) :

                                              Expectation conditioned on a finite-valued random variable -

                                              Equations
                                              Instances For
                                                Equations
                                                • One or more equations did not get rendered due to their size.
                                                Instances For
                                                  instance Finprob.instConstRV {τ : Type} {P : Finprob τ} :
                                                  Equations
                                                  instance Finprob.instRVadd {τ : Type} {P : Finprob τ} :
                                                  Equations
                                                  instance Finprob.instRVmul {τ : Type} {P : Finprob τ} [HMul ] :
                                                  Equations
                                                  def Finprob.dirac_ofsingleton {τ : Type} (t : τ) :

                                                  Construct a dirac distribution

                                                  Equations
                                                  Instances For
                                                    def Finprob.dirac_dist {τ : Type} [DecidableEq τ] (T : Finset τ) (t : { x : τ // x T }) :

                                                    Dirac distribution over T with P[t] = 1

                                                    Equations
                                                    Instances For
                                                      theorem Finprob.ind_and_eq_prod_ind {τ : Type} {P : Finprob τ} {B C : Finrv P Bool} (ω : τ) :
                                                      ω PFinprob.𝕀 ((B ∧ᵣ C).val ω) = (Finprob.𝕀 B.val) ω * (Finprob.𝕀 C.val) ω
                                                      theorem Finprob.exp_zero_cond {τ : Type} {P : Finprob τ} {X : Finrv P } {C : Finrv P Bool} (zero : ℙ[C] = 0) :
                                                      theorem Finprob.prob_zero_cond {τ : Type} {P : Finprob τ} {B C : Finrv P Bool} (zero : ℙ[C] = 0) :
                                                      ℙ[B|C] = 0
                                                      theorem Finprob.prob_ge_measure {τ : Type} {P : Finprob τ} {ν : Type} [DecidableEq ν] {V : Finset ν} {Y : Finrv P { x : ν // x V }} (ω : τ) :
                                                      ω Pℙ[Y ᵣ== Y.val ω] P.p ω
                                                      theorem Finprob.exp_omit_zero {τ : Type} {P : Finprob τ} {X : Finrv P } :
                                                      𝔼[X] = 𝔼[X.filter_zero]
                                                      theorem Finprob.exp_add_rv {τ : Type} {P : Finprob τ} {X Z : Finrv P } :
                                                      theorem Finprob.exp_const {τ : Type} {P : Finprob τ} {c : } :
                                                      𝔼[{ val := fun (x : τ) => c }] = c
                                                      theorem Finprob.exp_add_const {τ : Type} {P : Finprob τ} {X : Finrv P } {c : } :
                                                      𝔼[{ val := fun (x : τ) => c } + X] = c + 𝔼[X]
                                                      theorem Finprob.exp_cnd_rv_add_const {τ : Type} {P : Finprob τ} {ν : Type} [DecidableEq ν] {V : Finset ν} {X : Finrv P } {Y : Finrv P { x : ν // x V }} {c : } (ω : τ) :
                                                      ω P𝔼[{ val := fun (x : τ) => c } + X|ᵥY].val ω = c + 𝔼[X|ᵥY].val ω
                                                      theorem Finprob.exp_monotone {τ : Type} {P : Finprob τ} {X Z : Finrv P } (ge : ωP, ωP, P.prob.p ω > 0X.val ω Z.val ω) :
                                                      theorem Finprob.exp_congr {τ : Type} {P : Finprob τ} {X Z : Finrv P } (rv_same : ωP, P.supp ωX.val ω = Z.val ω) :

                                                      Expectations of identical rv are the same

                                                      theorem Finprob.exp_sum_val {τ : Type} {P : Finprob τ} (X : Finrv P ) :
                                                      𝔼[X] = xFinset.image X.val P, ℙ[X ᵣ== x] * x

                                                      Law of the unconscious statistician

                                                      theorem Finprob.exp_sum_val_cnd {τ : Type} {P : Finprob τ} (X : Finrv P ) (B : Finrv P Bool) :
                                                      𝔼[X|B] = xFinset.image X.val P, ℙ[X ᵣ== x|B] * x

                                                      Law of the unconscious statistician, conditional

                                                      theorem Finprob.exp_sum_val_cnd_rv {τ : Type} {P : Finprob τ} {ν : Type} [DecidableEq ν] {V : Finset ν} (X : Finrv P ) (Y : Finrv P { x : ν // x V }) (ω : τ) :
                                                      ω P𝔼[X|ᵥY].val ω = yV, ℙ[Y ᵣ== Y.val ω] * 𝔼[X|Y ᵣ== Y.val ω]

                                                      Law of the unconscious statistician, conditional random variable

                                                      theorem Finprob.total_probability {τ : Type} {P : Finprob τ} {ν : Type} [DecidableEq ν] {V : Finset ν} (B : Finrv P Bool) (Y : Finrv P { x : ν // x V }) :
                                                      ℙ[B] = y : { x : ν // x V }, ℙ[Y ᵣ== y] * ℙ[B|Y ᵣ== y]
                                                      theorem Finprob.total_expectation {τ : Type} {P : Finprob τ} {ν : Type} [DecidableEq ν] {V : Finset ν} (X : Finrv P ) (Y : Finrv P { x : ν // x V }) :
                                                      theorem Finprob.prob_prod_prob {τ₁ τ₂ : Type} {T₁ : Finset τ₁} {T₂ : Finset τ₂} (f : τ₁NNReal) (g : τ₁τ₂NNReal) (h1 : t₁T₁, f t₁ = 1) (h2 : t₁T₁, t₂T₂, g t₁ t₂ = 1) :
                                                      (∑ xT₁ ×ˢ T₂, match x with | (t₁, t₂) => f t₁ * g t₁ t₂) = 1

                                                      Product of a probability distribution with a dependent probability distributions is a probability distribution.

                                                      def Finprob.product_dep {τ₁ τ₂ : Type} {Ω₁ : Finset τ₁} (P₁ : Findist Ω₁) (Ω₂ : Finset τ₂) (p : τ₁τ₂NNReal) (h1 : ω₁Ω₁, ω₂Ω₂, p ω₁ ω₂ = 1) :
                                                      Findist (Ω₁ ×ˢ Ω₂)

                                                      Probability distribution as a product of a probability distribution and a dependent probability distribution.

                                                      Equations
                                                      • Finprob.product_dep P₁ Ω₂ p h1 = { p := fun (x : τ₁ × τ₂) => match x with | (ω₁, ω₂) => P₁.p ω₁ * p ω₁ ω₂, sumsto := }
                                                      Instances For
                                                        def Finprob.product_dep_pr {τ₁ τ₂ : Type} {Ω₁ : Finset τ₁} (P₁ : Findist Ω₁) (Ω₂ : Finset τ₂) (Q : τ₁Findist Ω₂) :
                                                        Findist (Ω₁ ×ˢ Ω₂)

                                                        Constructs a probability space as a product of a probability space and a dependent probability space.

                                                        Equations
                                                        • Finprob.product_dep_pr P₁ Ω₂ Q = { p := fun (x : τ₁ × τ₂) => match x with | (ω₁, ω₂) => P₁.p ω₁ * (Q ω₁).p ω₂, sumsto := }
                                                        Instances For
                                                          theorem Finprob.embed_preserve {τ₁ τ₂ : Type} (T₁ : Finset τ₁) (p : τ₁NNReal) (f : τ₁ τ₂) (f_linv : τ₂τ₁) (h : Function.LeftInverse f_linv f) :
                                                          t₂Finset.map f T₁, (p f_linv) t₂ = t₁T₁, p t₁

                                                          Embedding preserves a sum

                                                          def Finprob.embed {τ₁ τ₂ : Type} {Ω₁ : Finset τ₁} (P : Findist Ω₁) (e : τ₁ τ₂) (e_linv : τ₂τ₁) (h : Function.LeftInverse e_linv e) :

                                                          Embed the probability in a new space using e. Needs an inverse

                                                          Equations
                                                          • Finprob.embed P e e_linv h = { p := fun (t₂ : τ₂) => (P.p e_linv) t₂, sumsto := }
                                                          Instances For