-
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
base: master
Are you sure you want to change the base?
Changes from 20 commits
992890f
d941a54
9df4d7b
b3cad75
c826867
6f03269
68bfd70
e4e361a
380bb36
424c0f8
58f9c47
76ac71b
1c306a6
d4082d6
aeb66d1
12c60fd
1538f5d
883489e
a6de932
ea39ce4
384d6bc
745c376
e040b72
50ee095
782074f
83646d0
9c465a4
9fe7c83
ef5c7d0
9143114
cd0fcae
e6366f8
4a98f17
9026548
da98060
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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-random-real-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.random-real-variables-finite-probability-spaces public | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| # Expected value of random real variables in finite probability spaces | ||
|
|
||
| ```agda | ||
| module finite-probability-theory.expected-value-random-real-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.random-real-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 random real variable in a finite probability space" Agda=expected-value-random-real-variable-Finite-Probability-Space}} | ||
| of a | ||
| [random real variable](finite-probability-theory.random-real-variables-finite-probability-spaces.md) | ||
| `X` in a | ||
| [finite probability space](finite-probability-theory.finite-probability-spaces.md) | ||
| `(Ω , μ)` is the | ||
| [sum](group-theory.sums-of-finite-families-of-elements-abelian-groups.md) | ||
|
|
||
| $$ | ||
| ∑_{x ∈ Ω} X(x)μ(x). | ||
| $$ | ||
|
|
||
| Our definition follows Definition 2.2 of {{#cite Babai00}}. | ||
|
|
||
| ## Definitions | ||
|
|
||
| ### Expected value of a random real variable in a finite probability space | ||
|
||
|
|
||
| ```agda | ||
| module _ | ||
| {l : Level} (Ω : Finite-Probability-Space l) | ||
| (X : random-real-variable-Finite-Probability-Space Ω) | ||
| where | ||
|
|
||
| expected-value-random-real-variable-Finite-Probability-Space : ℝ lzero | ||
| expected-value-random-real-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}} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,156 @@ | ||
| # 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 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}}, although, there it is assumed that | ||
malarbol marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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 = | ||
| rec-coproduct | ||
| ( id) | ||
| ( ex-falso ∘ (is-nonempty-type-Finite-Probability-Space Ω)) | ||
| ( is-inhabited-or-empty-is-finite | ||
| ( is-finite-type-Finite-Probability-Space Ω)) | ||
malarbol marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| 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) | ||
| ``` | ||
malarbol marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ## References | ||
|
|
||
| {{#bibliography}} | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,92 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # 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). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| The **total measure** of a positive-distribution `μ` on a finite type `Ω` is the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fredrik-bakke marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [sum](group-theory.sums-of-finite-families-of-elements-abelian-groups.md) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $$ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ∑_{x ∈ Ω} μ(x). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $$ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
malarbol marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ## 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 μ = real-ℝ⁺ ∘ μ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
48
to
59
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're missing a universe level parameter in your definition here, and consequently everywhere else too
Suggested change
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you don't introduce this level parameter now you'll probably hit your face against resizing problems later on
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in general, your definitions should be in terms of
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I started out this way but since we only have the additive abelian group of real numbers at I think I'll mark this as a draft and wait for large algebraic structures and re-try this then.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The large algebraic structures you need should be in. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ### The total measure of a positive distribution on a finite type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ```agda | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| module _ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {l : Level} (Ω : Finite-Type l) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (μ : 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 Ω μ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ## Properties | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ### The total measure of a positive distribution on an empty type is zero | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ```agda | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| module _ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {l : Level} (Ω : Finite-Type l) (μ : 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 Ω μ = 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 Ω μ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.