-
Notifications
You must be signed in to change notification settings - Fork 47
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
bernoulli probability measure #895
Conversation
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 new interval stuff may be cleaner here. And I am worried about legibility if we have to add these [measure of ] annotations to every term.
theories/measure.v
Outdated
Variables (R : realType) (p : {nonneg R}) (p1 : (p%:num <= 1)%R). | ||
Local Open Scope ring_scope. | ||
|
||
Definition bernoulli : set _ -> \bar R := measure_add |
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 is a lot of text for what would be p 1_true + (1-p) 1_false
on paper. It took me ~3 minutes to read, which is maybe an indictment of my own reading comprehension. But still, I would love to make this definition clean, and handle the measure
stuff on the next line. Is there a way to do this?
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 are totally right. It is time to make this happen. I turn this PR into a draft and work on this ASAP.
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.
Part of the problem is to have the +
notation for non-negative measures. Wouldn't it be better to wait for the isZsemimodule
interface that comes with MathComp 2.0?
Note that the [measure of _] annotations are really here for compatibility with Coq 8.15. |
5296b6a
to
87540b5
Compare
theories/measure.v
Outdated
Variables (R : realType) (p : {i01 R}). | ||
|
||
Definition bernoulli : set _ -> \bar R := measure_add | ||
(mscale (NngNum (itv_ge0 p)) (dirac true)) |
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.
To hide NngNum (itv_ge0 p)
I was hoping to turn p%:inum
into an instance of non-negative number so as to use p%:inum%:nng
instead (which is not much more readable but a bit more in the spirit). The following addition to itv.v
is not enough:
Section tmp.
Context {T : numDomainType}.
Lemma i01_snum_subproof (p : {i01 T}) : Signed.spec 0%R ?=0 >=0 (Itv.r p).
Proof. by rewrite /=. Qed.
Canonical i01_snum (x : {i01 T}) := Signed.mk (i01_snum_subproof x).
End tmp.
Obviously, I am missing something. @proux01
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.
Sorry, I would also have expected it to work, I reduced it to the following minimal example
Section Example.
Variable R : realDomainType.
Check erefl : @eq R 0 (Signed.r _). (* correctly infers zero_snum *)
Check erefl : @eq R (Signed.r _) 0. (* same *)
Variable x : {i01 R}.
Check erefl : @eq R (Signed.r _) (Itv.r x). (* correctly infers i01_snum *)
Fail Check erefl : @eq R (Itv.r x) (Signed.r _). (* why? I would also have expected the same result *)
and unfortunately the phantom behind %:sgn
hence %:nng
seems closer to the second failing case.
@CohenCyril would you have an idea of what's happening?
Anyhow, all this advocates for the project of merging signed and itv in the future.
One year ago this PR introduced the Bernoulli probability measure. This update also defines the binomial distribution This update also defined "total" versions of the Bernoulli and Lemma bernoulliTE p U : 0 <= p <= 1 ->
(bernoulliT p U = p%:E * \d_true U + (`1-p)%:E * \d_false U)%E. which is close to the formulation that @zstone1 was expected We have been using all these distributions to verify a probabilistic I understand that @hoheinzollern has also been using the definition So, still not perfect but usable in practice, so what PS: Here is the only commit of the PR before update, |
fyi: @proux01 @hoheinzollern (comments also welcomed if you have time) |
I still have to move a few things around and to make the changelog and the doc |
@hoheinzollern @t6s the PR is now complete (with changelog and doc) |
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.
Looks good to me and ready to be merged, leaving two points to future PRs:
- Lemmas around measurable_fun_bool should be refactored. This should be easy and I have already prepared a branch to be PRed.
- Bernoulli is an instance of amore generic finitely-supported probability measure, which in turn an instance of adiscrete probability measure. This should be put in a hierarchy.
Co-authored-by: Takafumi Saikawa <[email protected]>
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.
Looks good to me.
* bernoulli, binomial, uniform distr Co-authored-by: Takafumi Saikawa <[email protected]>
Motivation for this change
Bernoulli probability measure as defined in
PR #749draft PR #912Things done/to do
CHANGELOG_UNRELEASED.md
Compatibility with MathComp 2.0
TODO: HB port
to make sure someone ports this PR tothe
hierarchy-builder
branch or I already opened an issue or PR (please cross reference).Automatic note to reviewers
Read this Checklist and put a milestone if possible.