-
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
35
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
35 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 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
Some comments aren't visible on the classic Files Changed page.
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,11 @@ | ||
| # Finite probability theory | ||
|
|
||
| ```agda | ||
| module finite-probability-theory where | ||
|
|
||
| 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 | ||
| ``` |
80 changes: 80 additions & 0 deletions
80
...-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,80 @@ | ||
| # 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 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 group-theory.sums-of-finite-families-of-elements-abelian-groups | ||
|
|
||
| open import real-numbers.addition-real-numbers | ||
| open import real-numbers.dedekind-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](group-theory.sums-of-finite-families-of-elements-abelian-groups.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 _ | ||
| {l : Level} (Ω : Finite-Probability-Space l) | ||
| (X : real-random-variable-Finite-Probability-Space Ω) | ||
| where | ||
|
|
||
| expected-value-real-random-variable-Finite-Probability-Space : ℝ lzero | ||
| expected-value-real-random-variable-Finite-Probability-Space = | ||
| sum-finite-Ab | ||
| ( abelian-group-add-ℝ-lzero) | ||
| ( finite-type-Finite-Probability-Space Ω) | ||
| ( λ x → | ||
| mul-ℝ | ||
| ( X x) | ||
| ( real-distribution-Finite-Probability-Space Ω x)) | ||
| ``` | ||
|
|
||
| ## References | ||
|
|
||
| {{#bibliography}} |
157 changes: 157 additions & 0 deletions
157
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,157 @@ | ||
| # 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 : (l : Level) → UU (lsuc l) | ||
| Finite-Probability-Space l = | ||
| Σ ( Finite-Type l) | ||
| ( probability-distribution-Finite-Type) | ||
|
|
||
| module _ | ||
| {l : Level} (Ω : Finite-Probability-Space l) | ||
| where | ||
|
|
||
| finite-type-Finite-Probability-Space : Finite-Type l | ||
| finite-type-Finite-Probability-Space = pr1 Ω | ||
|
|
||
| type-Finite-Probability-Space : UU l | ||
| 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 finite-type-Finite-Probability-Space | ||
| distribution-Finite-Probability-Space = pr1 (pr2 Ω) | ||
|
|
||
| real-distribution-Finite-Probability-Space : | ||
| type-Finite-Probability-Space → ℝ lzero | ||
| 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)) = | ||
| one-ℝ | ||
| eq-one-total-measure-distribution-Finite-Probability-Space = | ||
| pr2 (pr2 Ω) | ||
| ``` | ||
|
|
||
| ## Properties | ||
|
|
||
| ### A finite probability space is nonempty | ||
|
|
||
| ```agda | ||
| module _ | ||
| {l : Level} (Ω : Finite-Probability-Space l) | ||
| where | ||
|
|
||
| is-nonempty-type-Finite-Probability-Space : | ||
| is-nonempty (type-Finite-Probability-Space Ω) | ||
| is-nonempty-type-Finite-Probability-Space = | ||
| zero-is-not-one-ℝ ∘ absurd-is-empty-Finite-Probability-Space | ||
| where | ||
|
|
||
| absurd-is-empty-Finite-Probability-Space : | ||
| is-empty (type-Finite-Probability-Space Ω) → | ||
| zero-ℝ = one-ℝ | ||
| absurd-is-empty-Finite-Probability-Space H = | ||
| ( 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 _ | ||
| {l : Level} (Ω : Finite-Probability-Space l) | ||
| 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 l | ||
| inhabited-type-Finite-Probability-Space = | ||
| ( type-Finite-Probability-Space Ω , | ||
| is-inhabited-type-Finite-Probability-Space) | ||
|
|
||
| inhabited-finite-type-Finite-Probability-Space : Inhabited-Finite-Type l | ||
| inhabited-finite-type-Finite-Probability-Space = | ||
| ( finite-type-Finite-Probability-Space Ω , | ||
| is-inhabited-type-Finite-Probability-Space) | ||
| ``` | ||
|
|
||
| ## References | ||
|
|
||
| {{#bibliography}} | ||
95 changes: 95 additions & 0 deletions
95
src/finite-probability-theory/positive-distributions-on-finite-types.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,95 @@ | ||
| # Positive distributions on finite types | ||
|
|
||
| ```agda | ||
| module finite-probability-theory.positive-distributions-on-finite-types where | ||
| ``` | ||
|
|
||
| <details><summary>Imports</summary> | ||
|
|
||
| ```agda | ||
| open import foundation.empty-types | ||
| open import foundation.function-types | ||
| open import foundation.identity-types | ||
| open import foundation.universe-levels | ||
|
|
||
| open import group-theory.sums-of-finite-families-of-elements-abelian-groups | ||
|
|
||
| open import real-numbers.addition-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 univalent-combinatorics.finite-types | ||
| ``` | ||
|
|
||
| </details> | ||
|
|
||
| ## Idea | ||
|
|
||
| A | ||
| {{#concept "positive distribution" Disambiguation="on a finite type" Agda=positive-distribution-Finite-Type}} | ||
| on a [finite type](univalent-combinatorics.finite-types.md) `Ω` is a function | ||
| into the [positive real numbers](real-numbers.positive-real-numbers.md), | ||
| `Pr : Ω → ℝ⁺`. We interpret the type `Ω` as the collection of _atomic events_, | ||
| and `Pr(x)` as the (unnormalized) _probability_ that the atomic event `x` will | ||
| occur. Note that for positive distributions no atomic event can be _impossible_ | ||
| since `Pr(x)` is always strictly greater than `0`. The **total measure** of a | ||
| positive distribution `Pr` on a finite type `Ω` is the | ||
| [sum](group-theory.sums-of-finite-families-of-elements-abelian-groups.md) | ||
|
|
||
| $$ | ||
| ∑_{x ∈ Ω}\operatorname{Pr}(x). | ||
| $$ | ||
|
|
||
| ## Definitions | ||
|
|
||
| ### Positive distributions on finite types | ||
|
|
||
| ```agda | ||
| module _ | ||
| {l : Level} (Ω : Finite-Type l) | ||
| where | ||
|
|
||
| positive-distribution-Finite-Type : UU (lsuc lzero ⊔ l) | ||
| positive-distribution-Finite-Type = type-Finite-Type Ω → ℝ⁺ lzero | ||
|
|
||
| real-positive-distribution-Finite-Type : | ||
| positive-distribution-Finite-Type → type-Finite-Type Ω → ℝ lzero | ||
| real-positive-distribution-Finite-Type Pr = real-ℝ⁺ ∘ Pr | ||
| ``` | ||
|
|
||
| ### The total measure of a positive distribution on a finite type | ||
|
|
||
| ```agda | ||
| module _ | ||
| {l : Level} (Ω : Finite-Type l) | ||
| (Pr : positive-distribution-Finite-Type Ω) | ||
| where | ||
|
|
||
| total-measure-positive-distribution-Finite-Type : ℝ lzero | ||
| total-measure-positive-distribution-Finite-Type = | ||
| sum-finite-Ab | ||
| ( abelian-group-add-ℝ-lzero) | ||
| ( Ω) | ||
| ( real-positive-distribution-Finite-Type Ω Pr) | ||
| ``` | ||
|
|
||
| ## Properties | ||
|
|
||
| ### The total measure of a positive distribution on an empty type is zero | ||
|
|
||
| ```agda | ||
| module _ | ||
| {l : Level} (Ω : Finite-Type l) (Pr : positive-distribution-Finite-Type Ω) | ||
| where | ||
|
|
||
| is-zero-total-measure-positive-distribution-is-empty-Finite-Type : | ||
| is-empty (type-Finite-Type Ω) → | ||
| total-measure-positive-distribution-Finite-Type Ω Pr = zero-ℝ | ||
| is-zero-total-measure-positive-distribution-is-empty-Finite-Type H = | ||
| eq-zero-sum-finite-is-empty-Ab | ||
| ( abelian-group-add-ℝ-lzero) | ||
| ( Ω) | ||
| ( H) | ||
| ( real-positive-distribution-Finite-Type Ω Pr) | ||
| ``` |
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.