Skip to content

Conversation

@malarbol
Copy link
Collaborator

@malarbol malarbol commented Oct 24, 2025

This PR introduces a new module finite-probability-theory with 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:
    • functions from a finite type to ℝ⁺;
    • total measure of a positive distribution.
  • finite-probability-theory.probability-distributions-on-finite-types:
    • positive distributions with total measure equal to one.
  • finite-probability-theory.finite-probability-spaces:
    • finite types with a probability distribution;
    • finite probability types are inhabited.
  • finite-probability-theory.random-real-variables-finite-probability-spaces:
    • functions from a finite probability space to ℝ.
  • finite-probability-theory.expected-value-random-real-variables-finite-probability-spaces:
    • weighted sum of the values of the random variable.

@malarbol malarbol changed the title Bases for finite probability theory Basics of finite probability theory Oct 24, 2025
@fredrik-bakke
Copy link
Collaborator

Very cool project!

I wonder if this namespace should be called finite-probability-theory, since it's flavour is quite distinct from general probability theory.

@fredrik-bakke
Copy link
Collaborator

references :

By the way, you can add your reference to our references.bib file, so that you can cite it on the relevant pages!
See the guide at https://unimath.github.io/agda-unimath/CITING-SOURCES.html

@malarbol
Copy link
Collaborator Author

Very cool project!

Thanks. I hope it can be a new playground for all the new results on real numbers.

I wonder if this namespace should be called finite-probability-theory, since it's flavour is quite distinct from general probability theory.

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 finite-group-theory/group-theory.

@fredrik-bakke
Copy link
Collaborator

Let me know if you have a preferred color code for the label, since it is used for the dependency graph art :)

@malarbol
Copy link
Collaborator Author

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 finite-probability-theory you just created.

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).
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator

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...

Copy link
Collaborator Author

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.

Copy link
Collaborator

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.

Copy link
Collaborator Author

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?


## Definitions

### Expected value of a random real variable in a finite probability space
Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

@malarbol malarbol Oct 24, 2025

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 🎊

Copy link
Collaborator Author

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.

Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

@malarbol malarbol marked this pull request as ready for review October 24, 2025 20:04
@malarbol
Copy link
Collaborator Author

There's still a lot more to say but maybe it's good enough to start.


## Definitions

### Expected value of a random real variable in a finite probability space
Copy link
Collaborator

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.

Comment on lines 45 to 56
```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-ℝ⁺ ∘ μ
```
Copy link
Collaborator

@fredrik-bakke fredrik-bakke Oct 25, 2025

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

Suggested change
```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-ℝ⁺ ∘ μ
```

Copy link
Collaborator

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

Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator

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.

Comment on lines 79 to 97
### 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'))
```
Copy link
Collaborator

@fredrik-bakke fredrik-bakke Oct 25, 2025

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.

Copy link
Collaborator

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.

Comment on lines 67 to 77
### 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
```
Copy link
Collaborator

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.

@malarbol malarbol marked this pull request as draft October 25, 2025 15:02
@fredrik-bakke
Copy link
Collaborator

The large ring of real numbers has now been contributed to the library #1664 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants