-
Notifications
You must be signed in to change notification settings - Fork 91
Basics of finite probability theory #1626
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
malarbol
wants to merge
47
commits into
UniMath:master
Choose a base branch
from
malarbol:probability-theory
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
992890f
finite probability spaces & random variables
malarbol d941a54
constant random variables
malarbol 9df4d7b
fix link
malarbol b3cad75
Merge branch 'master' into probability-theory
malarbol c826867
rename module finite-probability-theory
malarbol 6f03269
fix links
malarbol 68bfd70
format
malarbol e4e361a
typo
malarbol 380bb36
rename measure -> distribution
malarbol 424c0f8
add references
malarbol 58f9c47
fix link
malarbol 76ac71b
zero-is-not-one-R
malarbol 1c306a6
finite probability spaces are inhabited
malarbol d4082d6
atomic random variables
malarbol aeb66d1
fix name
malarbol 12c60fd
explicit references sections
malarbol 1538f5d
Update references.bib
malarbol 883489e
rephrase non-empty consequence/hypothesis for finite probability spaces
malarbol a6de932
re-rephrase
malarbol ea39ce4
Update src/finite-probability-theory/finite-probability-spaces.lagda.md
malarbol 384d6bc
Update src/finite-probability-theory/finite-probability-spaces.lagda.md
malarbol 745c376
Update src/finite-probability-theory/probability-distributions-on-fin…
malarbol e040b72
Update src/finite-probability-theory/positive-distributions-on-finite…
malarbol 50ee095
Use Pr instead of \mu
malarbol 782074f
format
malarbol 83646d0
Merge branch 'master' into probability-theory
malarbol 9c465a4
rename real-random-variable
malarbol 9fe7c83
use prop-double-negation-elim-is-inhabited-or-empty
malarbol ef5c7d0
fix link
malarbol 9143114
fix link
malarbol cd0fcae
Merge branch 'master' into probability-theory
malarbol e6366f8
Merge branch 'master' into probability-theory
malarbol 4a98f17
Merge branch 'master' into probability-theory
malarbol 9026548
Merge branch 'master' into probability-theory
malarbol da98060
Merge branch 'master' into probability-theory
malarbol 3d8c254
Merge branch 'master' into probability-theory
malarbol 96b9597
Merge branch 'master' into probability-theory
malarbol 038493c
WIP
malarbol c432d17
fix
malarbol e0942cd
WIP level polymorphism
malarbol 94b213f
random variables + level
malarbol 0a704d9
level expected value
malarbol a5170e7
format
malarbol 9ecb149
split modules
malarbol f5d07ff
typo
malarbol 94f733e
typo
malarbol cf537c4
typo
malarbol File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Finite probability theory | ||
|
|
||
| ```agda | ||
| module finite-probability-theory where | ||
|
|
||
| open import finite-probability-theory.atomic-real-random-variables-finite-probability-spaces public | ||
| open import finite-probability-theory.constant-real-random-variables-finite-probability-spaces public | ||
| open import finite-probability-theory.expected-value-real-random-variables-finite-probability-spaces public | ||
| open import finite-probability-theory.finite-probability-spaces public | ||
| open import finite-probability-theory.positive-distributions-on-finite-types public | ||
| open import finite-probability-theory.probability-distributions-on-finite-types public | ||
| open import finite-probability-theory.real-random-variables-finite-probability-spaces public | ||
| ``` |
59 changes: 59 additions & 0 deletions
59
...bability-theory/atomic-real-random-variables-finite-probability-spaces.lagda.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| # Atomic real random variables in finite probability spaces | ||
|
|
||
| ```agda | ||
| module finite-probability-theory.atomic-real-random-variables-finite-probability-spaces where | ||
| ``` | ||
|
|
||
| <details><summary>Imports</summary> | ||
|
|
||
| ```agda | ||
| open import finite-probability-theory.finite-probability-spaces | ||
| open import finite-probability-theory.real-random-variables-finite-probability-spaces | ||
|
|
||
| open import foundation.coproduct-types | ||
| open import foundation.identity-types | ||
| open import foundation.universe-levels | ||
|
|
||
| open import real-numbers.dedekind-real-numbers | ||
| open import real-numbers.rational-real-numbers | ||
|
|
||
| open import univalent-combinatorics.equality-finite-types | ||
| open import univalent-combinatorics.finite-types | ||
| ``` | ||
|
|
||
| </details> | ||
|
|
||
| ## Idea | ||
|
|
||
| The | ||
| {{#concept "atomic real random variable" Disambiguation="in a finite probability space" Agda=atomic-real-random-variable-Finite-Probability-Space}} | ||
| in a | ||
| [finite probability space](finite-probability-theory.finite-probability-spaces.md) | ||
| `(Ω , Pr)` at `e : Ω` is the | ||
| [real random variable](finite-probability-theory.real-random-variables-finite-probability-spaces.md) | ||
| `X : Ω → ℝ` such that: | ||
|
|
||
| - `X e = 1`; | ||
| - `∀ (e' : Ω) (e' ≠ e) → X e = 0`. | ||
|
|
||
| ## Definition | ||
|
|
||
| ### Atomic real random variables in a finite probability space | ||
|
|
||
| ```agda | ||
| module _ | ||
| {l1 l2 : Level} (Ω : Finite-Probability-Space l1 l2) | ||
| (e : type-Finite-Probability-Space Ω) | ||
| where | ||
|
|
||
| atomic-real-random-variable-Finite-Probability-Space : | ||
| real-random-variable-Finite-Probability-Space lzero Ω | ||
| atomic-real-random-variable-Finite-Probability-Space e' = | ||
| rec-coproduct | ||
| ( λ _ → one-ℝ) | ||
| ( λ _ → zero-ℝ) | ||
| ( has-decidable-equality-is-finite | ||
| ( is-finite-type-Finite-Probability-Space Ω) | ||
| ( e) | ||
| ( e')) | ||
| ``` |
44 changes: 44 additions & 0 deletions
44
...bility-theory/constant-real-random-variables-finite-probability-spaces.lagda.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # Constnant real random variables in finite probability spaces | ||
|
|
||
| ```agda | ||
| module finite-probability-theory.constant-real-random-variables-finite-probability-spaces where | ||
| ``` | ||
|
|
||
| <details><summary>Imports</summary> | ||
|
|
||
| ```agda | ||
| open import finite-probability-theory.finite-probability-spaces | ||
| open import finite-probability-theory.real-random-variables-finite-probability-spaces | ||
|
|
||
| open import foundation.universe-levels | ||
|
|
||
| open import group-theory.sums-of-finite-families-of-elements-abelian-groups | ||
|
|
||
| open import real-numbers.dedekind-real-numbers | ||
| ``` | ||
|
|
||
| </details> | ||
|
|
||
| ## Idea | ||
|
|
||
| Any [real number](real-numbers.dedekind-real-numbers.md) `x` defines a | ||
| {{#concept "constant real random variable" Disambiguation="in a finite probability space" Agda=const-real-random-variable-Finite-Probability-Space}} | ||
| on any | ||
| [finite probability space](finite-probability-theory.finite-probability-spaces.md) | ||
| `Ω`: the | ||
| [real random variable](finite-probability-theory.real-random-variables-finite-probability-spaces.md) | ||
| `X : (e : Ω) ↦ x`. | ||
|
|
||
| ## Definitions | ||
|
|
||
| ### Constant random variables in a finite probability space | ||
|
|
||
| ```agda | ||
| module _ | ||
| {l1 l2 : Level} (Ω : Finite-Probability-Space l1 l2) | ||
| where | ||
|
|
||
| const-real-random-variable-Finite-Probability-Space : | ||
| (x : ℝ l2) → real-random-variable-Finite-Probability-Space l2 Ω | ||
| const-real-random-variable-Finite-Probability-Space x _ = x | ||
| ``` |
81 changes: 81 additions & 0 deletions
81
...-theory/expected-value-real-random-variables-finite-probability-spaces.lagda.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| # Expected value of real random variables in finite probability spaces | ||
|
|
||
| ```agda | ||
| module finite-probability-theory.expected-value-real-random-variables-finite-probability-spaces where | ||
| ``` | ||
|
|
||
| <details><summary>Imports</summary> | ||
|
|
||
| ```agda | ||
| open import commutative-algebra.sums-of-finite-families-of-elements-commutative-rings | ||
|
|
||
| open import finite-probability-theory.finite-probability-spaces | ||
| open import finite-probability-theory.positive-distributions-on-finite-types | ||
| open import finite-probability-theory.probability-distributions-on-finite-types | ||
| open import finite-probability-theory.real-random-variables-finite-probability-spaces | ||
|
|
||
| open import foundation.dependent-pair-types | ||
| open import foundation.empty-types | ||
| open import foundation.function-types | ||
| open import foundation.identity-types | ||
| open import foundation.inhabited-types | ||
| open import foundation.propositions | ||
| open import foundation.sets | ||
| open import foundation.subtypes | ||
| open import foundation.transport-along-identifications | ||
| open import foundation.universe-levels | ||
|
|
||
| open import real-numbers.addition-real-numbers | ||
| open import real-numbers.dedekind-real-numbers | ||
| open import real-numbers.large-ring-of-real-numbers | ||
| open import real-numbers.multiplication-real-numbers | ||
| open import real-numbers.positive-real-numbers | ||
| open import real-numbers.rational-real-numbers | ||
| open import real-numbers.strict-inequality-real-numbers | ||
|
|
||
| open import univalent-combinatorics.finite-types | ||
| ``` | ||
|
|
||
| </details> | ||
|
|
||
| ## Idea | ||
|
|
||
| The | ||
| {{#concept "expected value" Disambiguation="of a real random variable in a finite probability space" Agda=expected-value-real-random-variable-Finite-Probability-Space}} | ||
| of a | ||
| [real random variable](finite-probability-theory.real-random-variables-finite-probability-spaces.md) | ||
| `X` in a | ||
| [finite probability space](finite-probability-theory.finite-probability-spaces.md) | ||
| `(Ω , Pr)` is the | ||
| [sum](commutative-algebra.sums-of-finite-families-of-elements-commutative-rings.md) | ||
|
|
||
| $$ | ||
| ∑_{x ∈ Ω} X(x)\operatorname{Pr}(x). | ||
| $$ | ||
|
|
||
| Our definition follows Definition 2.2 of {{#cite Babai00}}. | ||
|
|
||
| ## Definitions | ||
|
|
||
| ### Expected value of a real random variable in a finite probability space | ||
|
|
||
| ```agda | ||
| module _ | ||
| {l1 l2 l3 : Level} (Ω : Finite-Probability-Space l1 l2) | ||
| (X : real-random-variable-Finite-Probability-Space l3 Ω) | ||
| where | ||
|
|
||
| expected-value-real-random-variable-Finite-Probability-Space : ℝ (l2 ⊔ l3) | ||
| expected-value-real-random-variable-Finite-Probability-Space = | ||
| sum-finite-Commutative-Ring | ||
| ( commutative-ring-ℝ (l2 ⊔ l3)) | ||
| ( finite-type-Finite-Probability-Space Ω) | ||
| ( λ x → | ||
| mul-ℝ | ||
| ( X x) | ||
| ( real-distribution-Finite-Probability-Space Ω x)) | ||
| ``` | ||
|
|
||
| ## References | ||
|
|
||
| {{#bibliography}} |
150 changes: 150 additions & 0 deletions
150
src/finite-probability-theory/finite-probability-spaces.lagda.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,150 @@ | ||
| # Finite probability spaces | ||
|
|
||
| ```agda | ||
| module finite-probability-theory.finite-probability-spaces where | ||
| ``` | ||
|
|
||
| <details><summary>Imports</summary> | ||
|
|
||
| ```agda | ||
| open import finite-probability-theory.positive-distributions-on-finite-types | ||
| open import finite-probability-theory.probability-distributions-on-finite-types | ||
|
|
||
| open import foundation.coproduct-types | ||
| open import foundation.dependent-pair-types | ||
| open import foundation.empty-types | ||
| open import foundation.function-types | ||
| open import foundation.identity-types | ||
| open import foundation.inhabited-types | ||
| open import foundation.propositions | ||
| open import foundation.sets | ||
| open import foundation.subtypes | ||
| open import foundation.transport-along-identifications | ||
| open import foundation.universe-levels | ||
|
|
||
| open import group-theory.sums-of-finite-families-of-elements-abelian-groups | ||
|
|
||
| open import logic.propositional-double-negation-elimination | ||
|
|
||
| open import real-numbers.addition-real-numbers | ||
| open import real-numbers.apartness-real-numbers | ||
| open import real-numbers.dedekind-real-numbers | ||
| open import real-numbers.positive-real-numbers | ||
| open import real-numbers.rational-real-numbers | ||
| open import real-numbers.strict-inequality-real-numbers | ||
|
|
||
| open import univalent-combinatorics.finite-types | ||
| open import univalent-combinatorics.inhabited-finite-types | ||
| ``` | ||
|
|
||
| </details> | ||
|
|
||
| ## Idea | ||
|
|
||
| A {{#concept "finite probability space" Agda=Finite-Probability-Space}} is a | ||
| [finite type](univalent-combinatorics.finite-types.md) equipped with a | ||
| [probability distribution](finite-probability-theory.probability-distributions-on-finite-types.md). | ||
|
|
||
| Any finite probability space is [inhabited](foundation.inhabited-types.md). | ||
|
|
||
| Our definitions follows {{#cite Babai00}}, except, there it is assumed that the | ||
| underlying type is [nonempty](foundation-core.empty-types.md), but this follows | ||
| from the condition of having | ||
| [total measure](finite-probability-theory.positive-distributions-on-finite-types.md) | ||
| equal to 1. | ||
|
|
||
| ## Definitions | ||
|
|
||
| ### Finite probability spaces | ||
|
|
||
| ```agda | ||
| Finite-Probability-Space : (l1 l2 : Level) → UU (lsuc l1 ⊔ lsuc l2) | ||
| Finite-Probability-Space l1 l2 = | ||
| Σ ( Finite-Type l1) | ||
| ( probability-distribution-Finite-Type l2) | ||
|
|
||
| module _ | ||
| {l1 l2 : Level} (Ω : Finite-Probability-Space l1 l2) | ||
| where | ||
|
|
||
| finite-type-Finite-Probability-Space : Finite-Type l1 | ||
| finite-type-Finite-Probability-Space = pr1 Ω | ||
|
|
||
| type-Finite-Probability-Space : UU l1 | ||
| type-Finite-Probability-Space = | ||
| type-Finite-Type finite-type-Finite-Probability-Space | ||
|
|
||
| is-finite-type-Finite-Probability-Space : | ||
| is-finite type-Finite-Probability-Space | ||
| is-finite-type-Finite-Probability-Space = | ||
| is-finite-type-Finite-Type finite-type-Finite-Probability-Space | ||
|
|
||
| distribution-Finite-Probability-Space : | ||
| positive-distribution-Finite-Type l2 finite-type-Finite-Probability-Space | ||
| distribution-Finite-Probability-Space = pr1 (pr2 Ω) | ||
|
|
||
| real-distribution-Finite-Probability-Space : | ||
| type-Finite-Probability-Space → ℝ l2 | ||
| real-distribution-Finite-Probability-Space = | ||
| real-positive-distribution-Finite-Type | ||
| ( finite-type-Finite-Probability-Space) | ||
| ( distribution-Finite-Probability-Space) | ||
|
|
||
| eq-one-total-measure-distribution-Finite-Probability-Space : | ||
| ( total-measure-positive-distribution-Finite-Type | ||
| ( finite-type-Finite-Probability-Space) | ||
| ( distribution-Finite-Probability-Space)) = | ||
| ( raise-one-ℝ l2) | ||
| eq-one-total-measure-distribution-Finite-Probability-Space = pr2 (pr2 Ω) | ||
| ``` | ||
|
|
||
| ## Properties | ||
|
|
||
| ### A finite probability space is nonempty | ||
|
|
||
| ```agda | ||
| module _ | ||
| {l1 l2 : Level} (Ω : Finite-Probability-Space l1 l2) | ||
| where | ||
|
|
||
| is-nonempty-type-Finite-Probability-Space : | ||
| is-nonempty (type-Finite-Probability-Space Ω) | ||
| is-nonempty-type-Finite-Probability-Space H = | ||
| neq-raise-zero-one-ℝ l2 | ||
| ( ( inv | ||
| ( is-zero-total-measure-positive-distribution-is-empty-Finite-Type | ||
| ( finite-type-Finite-Probability-Space Ω) | ||
| ( distribution-Finite-Probability-Space Ω) | ||
| ( H))) ∙ | ||
| ( eq-one-total-measure-distribution-Finite-Probability-Space Ω)) | ||
| ``` | ||
|
|
||
| ### A finite probability space is inhabited | ||
|
|
||
| ```agda | ||
| module _ | ||
| {l1 l2 : Level} (Ω : Finite-Probability-Space l1 l2) | ||
| where | ||
|
|
||
| is-inhabited-type-Finite-Probability-Space : | ||
| is-inhabited (type-Finite-Probability-Space Ω) | ||
| is-inhabited-type-Finite-Probability-Space = | ||
| prop-double-negation-elim-is-inhabited-or-empty | ||
| ( is-inhabited-or-empty-is-finite | ||
| ( is-finite-type-Finite-Probability-Space Ω)) | ||
| ( is-nonempty-type-Finite-Probability-Space Ω) | ||
|
|
||
| inhabited-type-Finite-Probability-Space : Inhabited-Type l1 | ||
| inhabited-type-Finite-Probability-Space = | ||
| ( type-Finite-Probability-Space Ω , | ||
| is-inhabited-type-Finite-Probability-Space) | ||
|
|
||
| inhabited-finite-type-Finite-Probability-Space : Inhabited-Finite-Type l1 | ||
| inhabited-finite-type-Finite-Probability-Space = | ||
| ( finite-type-Finite-Probability-Space Ω , | ||
| is-inhabited-type-Finite-Probability-Space) | ||
| ``` | ||
|
|
||
| ## References | ||
|
|
||
| {{#bibliography}} | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.