Skip to content
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

[Merged by Bors] - feat(probability_theory/notation): add notations for expected value, conditional expectation #9469

Closed
wants to merge 9 commits into from

Conversation

RemyDegenne
Copy link
Collaborator

@RemyDegenne RemyDegenne commented Sep 30, 2021

When working in probability theory, the measure on the space is most often implicit. With our current notations for measure spaces, that means writing volume in a lot of places. To avoid that and introduce notations closer to the usual practice, this PR defines

  • 𝔼[X] for the expected value (integral) of a function X over the volume measure,
  • P[X] for the expected value over the measure P,
  • 𝔼[X | hm] for the conditional expectation with respect to the volume,
  • X =ₐₛ Y for X =ᵐ[volume] Y and similarly for X ≤ᵐ[volume] Y,
  • ∂P/∂Q for P.rn_deriv Q

All notations are localized to the probability_theory namespace.


I'd like to hear opinions about the notations and since I have no idea of how to set binding powers, I'd like some comments on that as well.

Open in Gitpod

@RemyDegenne RemyDegenne added the RFC Request for comment label Sep 30, 2021
variables {α E : Type*} [measure_space α] {ℙ ℙ' : measure α} [measurable_space E] [normed_group E]
[normed_space ℝ E] [borel_space E] [second_countable_topology E] [complete_space E] {X Y : α → E}

example : ℙ[X] = ∫ a, X a ∂ℙ := rfl
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really like this one. I'd prefer to be a notation for volume, and then ℙ s would be the probability of the set s. Or maybe rather for the real-valued version of the measure (do we already have an API around this for finite measures?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right that ℙ s should be the probability of a set, either as notation for volume s or as a consequence of your proposal of being a notation for the volume. In any case, I should not use as a name for a measure.

But it does not rule out µ[X] where µ is the measure, and not part of the notation. I think those two notations could go well together.
If is a notation for volume as you suggest, then with the µ[X] notation for expected value, ℙ[X] would be a way to write the expected value of X. Or we can still define the 𝔼[X] notation on top of that if we prefer.

I really want a nice way to write an expectation with respect to a non-volume measure, since almost every paper I write uses a change of probability measure somewhere (I realize that this contradicts the first sentence of the PR description, in which I say that the measure is often implicit).

The notations I see most often in real math to make the measure explicit are 𝔼_P[X] or 𝔼_{X∼P}[X] (with subscripts), which is not something we can do. The P[X] notation is also something I've seen used by some people to denote the expected value under P, and that one is mathlib-compatible.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am perfectly ok with µ[X], although maybe 𝔼[X; µ] would also work. I'll let you choose whichever you prefer.

Copy link
Collaborator Author

@RemyDegenne RemyDegenne Sep 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding the real vs ennreal issue for ℙ s, I think it could be nice to have it real because working with ennreal is not fun.
But that means that cannot be a notation for the volume. ℙ s has to be notation for the real-valued finite measure applied to s, or has to be notation for the real-valued measure, but it then cannot be used to write ℙ[X] for example.

I will leave that out for now and look at what we have about that real-valued version of a finite measure.

Copy link
Collaborator

@kkytola kkytola Oct 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that often ennreal values for probabilities are not fun. Currently measure_theory.finite_measure.has_coe_to_fun and measure_theory.probability_measure.has_coe_to_fun yield the underlying measures of sets composed with ennreal.to_nnreal, but there is no API and this is therefore largely untested for now.

One possibility would be to try something similar to dist vs nndist. For example one could have a typeclass has_nnmeasure, instantiated either under the assumption [is_finite_measure µ] or for the types finite_measure and probability_measure. Notation should be chosen anyway. And it would require some API, but nndist has worked well for me recently.

I am not suggesting anything for this PR, just commenting on the status of "real-valued version of a finite measure".

@RemyDegenne RemyDegenne added the needs-documentation This PR is missing required documentation label Sep 30, 2021
@RemyDegenne RemyDegenne added awaiting-review The author would like community review of the PR and removed RFC Request for comment needs-documentation This PR is missing required documentation labels Oct 2, 2021
@sgouezel
Copy link
Collaborator

sgouezel commented Oct 4, 2021

Let's merge this for now. As for the binding power, I have no clue either, so we will see if there are friction points when using the notations, and solve them if/when needed.
bors r+

@github-actions github-actions bot added ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.) and removed awaiting-review The author would like community review of the PR labels Oct 4, 2021
bors bot pushed a commit that referenced this pull request Oct 4, 2021
…conditional expectation (#9469)

When working in probability theory, the measure on the space is most often implicit. With our current notations for measure spaces, that means writing `volume` in a lot of places. To avoid that and introduce notations closer to the usual practice, this PR defines
- `𝔼[X]` for the expected value (integral) of a function `X` over the volume measure,
- `P[X]` for the expected value over the measure `P`,
- `𝔼[X | hm]` for the conditional expectation with respect to the volume,
- `X =ₐₛ Y` for `X =ᵐ[volume] Y` and similarly for `X ≤ᵐ[volume] Y`,
- `∂P/∂Q` for `P.rn_deriv Q`

All notations are localized to the `probability_theory` namespace.
@bors
Copy link

bors bot commented Oct 4, 2021

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title feat(probability_theory/notation): add notations for expected value, conditional expectation [Merged by Bors] - feat(probability_theory/notation): add notations for expected value, conditional expectation Oct 4, 2021
@bors bors bot closed this Oct 4, 2021
@bors bors bot deleted the proba_notation branch October 4, 2021 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants