-
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?
Conversation
|
Very cool project! I wonder if this namespace should be called |
By the way, you can add your reference to our |
Thanks. I hope it can be a new playground for all the new results on real numbers.
Sure. I thought that future results on non-finite probability theory could also go here, but having them separated would be coherent with the current division |
|
Let me know if you have a preferred color code for the label, since it is used for the dependency graph art :) |
I'm ok with the one from the new label |
| A | ||
| {{#concept "measure" Disambiguation="on a finite type" Agda=measure-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). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this not be nonnegative real numbers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'v seen contradicting references for this but there seems to be a slight preference for only considering positive distributions.
Moreover, in our context, I think it will be easier to work with: for a nonnegative real number we can't decide if it's zero or positive so we won't be able to identify elements with zero-measure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okiedokie. Please make sure to reflect this choice in the naming though, since in the real world an event can be impossible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure where you stand on the positive vs. nonnegative debate. I added the reference to Balai00 but didn't emphasize on the positive part. Maybe I should?
Also, I have the feeling that the notion of "impossible events" will appear later, considering random variables (functions from the finite probability space to ℝ) and, then, some subsets of ℝ will have empty pre-image, and "zero-measure". But I haven't really worked that part out, yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would definitely expect to have to use nonnegative numbers -- impossible events, the intersection of exclusive events...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would definitely expect to have to use nonnegative numbers -- impossible events, the intersection of exclusive events...
I think this will come later, when we define events in a finite probability space as subsets of the underlying type. Then the probability of an event will be the sum of the probabilities of its elements (decidability issues to be discussed) and the empty event will have zero probability. Nonetheless it really seems reasonable to have positive values for atomic distributions on finite types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A nonempty event could also be impossible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A nonempty event could also be impossible.
yes.
I have the feeling I'm not explaining myself well.
I can try to change the definition to consider nonnegative distributions if you really want to. Do you have reference that construct finite probability spaces this way?
src/finite-probability-theory/finite-probability-spaces.lagda.md
Outdated
Show resolved
Hide resolved
|
|
||
| ## Definitions | ||
|
|
||
| ### Expected value of a random real variable in a finite probability space |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems probably true of any rational ring, FWIW? It might help variables more usefully expressed in terms of integers and rational numbers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about it too but I think I'd need "rational-positive-distributions" for that (I'd need the coefficients μ(x) to be rational); maybe it would be a good thing to have. I can give it a go or feel free to join in if you want to!
On the other hand, we'll probably have the concept of "real ring" sometimes in the future so we'll be able to consider random variables in real rings then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed you made quite some progress on real multiplication etc. Do we have the ring of real numbers already or are there still some missing laws? I suspect distributivity must be quite painful 🫤 EDIT: I see distributivity is already there 🎊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[...] Do we have the ring of real numbers already or are there still some missing laws? [...]
you're probably working on large rings and such. Let's wait then. I think we need som ring structure on ℝ to follow with more interesting results.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, see #1586. The ring at lzero was originally contributed, but in the end it was concluded to wait for the large ring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect. I'll just wait then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, do you mean you will wait with finishing this PR until that one has been merged? If so, please mark this one as a draft.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, do you mean you will wait with finishing this PR until that one has been merged? If so, please mark this one as a draft.
Yes. One of the endgoal is to prove that the space of real random variables is an ℝ-module and the expected value a linear map. For this I'll need more algebraic structure. And I'll need more time to figure out the level-polymorphic construction.
Thanks for your help anyways. Sorry for your time.
src/finite-probability-theory/random-real-variables-finite-probability-spaces.lagda.md
Outdated
Show resolved
Hide resolved
|
There's still a lot more to say but maybe it's good enough to start. |
Co-authored-by: Fredrik Bakke <[email protected]>
src/finite-probability-theory/finite-probability-spaces.lagda.md
Outdated
Show resolved
Hide resolved
src/finite-probability-theory/finite-probability-spaces.lagda.md
Outdated
Show resolved
Hide resolved
|
|
||
| ## Definitions | ||
|
|
||
| ### Expected value of a random real variable in a finite probability space |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, see #1586. The ring at lzero was originally contributed, but in the end it was concluded to wait for the large ring.
Co-authored-by: Fredrik Bakke <[email protected]>
src/finite-probability-theory/finite-probability-spaces.lagda.md
Outdated
Show resolved
Hide resolved
src/finite-probability-theory/finite-probability-spaces.lagda.md
Outdated
Show resolved
Hide resolved
src/finite-probability-theory/positive-distributions-on-finite-types.lagda.md
Outdated
Show resolved
Hide resolved
src/finite-probability-theory/positive-distributions-on-finite-types.lagda.md
Show resolved
Hide resolved
| ```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-ℝ⁺ ∘ μ | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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
| ```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-ℝ⁺ ∘ μ | |
| ``` | |
| ```agda | |
| module _ | |
| {l1 : Level} (l2 : Level) (Ω : Finite-Type l1) | |
| where | |
| positive-distribution-Finite-Type : UU (l1 ⊔ lsuc l2) | |
| positive-distribution-Finite-Type = type-Finite-Type Ω → ℝ⁺ l2 | |
| module _ | |
| {l1 l2 : Level} (Ω : Finite-Type l1) | |
| where | |
| real-positive-distribution-Finite-Type : | |
| positive-distribution-Finite-Type l2 Ω → type-Finite-Type Ω → ℝ l2 | |
| real-positive-distribution-Finite-Type μ = real-ℝ⁺ ∘ μ | |
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in general, your definitions should be in terms of ℝ at a universe level always. Always maximize the number of universe level parameters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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 lzero, to define even the simplest thing like the total measure, I needed to restrict to lzero.
I think I'll mark this as a draft and wait for large algebraic structures and re-try this then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The large algebraic structures you need should be in.
src/finite-probability-theory/probability-distributions-on-finite-types.lagda.md
Outdated
Show resolved
Hide resolved
| ### Atomic random variables in a finite probability space | ||
|
|
||
| ```agda | ||
| module _ | ||
| {l : Level} (Ω : Finite-Probability-Space l) | ||
| (e : type-Finite-Probability-Space Ω) | ||
| where | ||
|
|
||
| atomic-random-real-variable-Finite-Probability-Space : | ||
| random-real-variable-Finite-Probability-Space Ω | ||
| atomic-random-real-variable-Finite-Probability-Space e' = | ||
| rec-coproduct | ||
| ( λ _ → one-ℝ) | ||
| ( λ _ → zero-ℝ) | ||
| ( has-decidable-equality-is-finite | ||
| ( is-finite-type-Finite-Probability-Space Ω) | ||
| ( e) | ||
| ( e')) | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should IMO be defined in terms of a general large semiring, and on its own page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean a general semiring.
| ### Constant random variables in a finite probability space | ||
|
|
||
| ```agda | ||
| module _ | ||
| {l : Level} (Ω : Finite-Probability-Space l) | ||
| where | ||
|
|
||
| const-random-real-variable-Finite-Probablity-Space : | ||
| (x : ℝ lzero) → random-real-variable-Finite-Probability-Space Ω | ||
| const-random-real-variable-Finite-Probablity-Space x _ = x | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can also have a separate page.
...e-probability-theory/expected-value-random-real-variables-finite-probability-spaces.lagda.md
Outdated
Show resolved
Hide resolved
Co-authored-by: Fredrik Bakke <[email protected]>
…ite-types.lagda.md Co-authored-by: Fredrik Bakke <[email protected]>
…-types.lagda.md Co-authored-by: Fredrik Bakke <[email protected]>
|
The large ring of real numbers has now been contributed to the library #1664 :) |
This PR introduces a new module
finite-probability-theorywith some basic definitions on finite probability theory, following https://people.cs.uchicago.edu/~laci/reu02/prob.pdf.finite-probability-theory.positive-distributions-on-finite-types:finite-probability-theory.probability-distributions-on-finite-types:finite-probability-theory.finite-probability-spaces:finite-probability-theory.random-real-variables-finite-probability-spaces:finite-probability-theory.expected-value-random-real-variables-finite-probability-spaces: