-
Notifications
You must be signed in to change notification settings - Fork 416
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
Add minimum
, maximum
, extrema
for AbstractMvNormal
and Product
#1319
Conversation
It seems weird to me to define |
I believe the implementation provided satisfies the lexicographic order of |
Would making something like the following be something you are willing to have merged into Distributions.jl?
|
The docstrings of |
I first thought the same, but I convinced myself this is correct:
After figuring it out I added a clarification to the doc string too: |
I think a better approach would be to define However, this would involve more changes and probably take some time until it would be available, so maybe the easiest short-term solution for you would be to define a custom interface in your package instead of in Distributions. |
It would also be more consistent with the current univariate implementation since there |
But it's the right thing to define, the proposed |
I didn't know that It would be good to add |
I am happy to add it for other distributions, however, I am not familiar with many of them and it isn't obvious what this should be in all cases. For example, should Dirichlet be
|
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 made some suggestions.
Ah, that's a nice example for why it would be useful to define function Base.minimum(d::Dirichlet)
n = length(d)
return [i < n ? zero(eltype(d)) : one(eltype(d)) for i in 1:n]
end
function Base.maximum(d::Dirichlet)
return [i == 1 ? one(eltype(d)) : zero(eltype(d)) for i in 1:length(d)]
end But probably |
Yes, on slack I recommended to go for
|
Since the support is an open set? The nice thing about DomainSets and similar packages is that they provide support (pun intended) for open and closed sets and half-open intervals. |
This doesn't seem correct to me. Maybe I'm trivializing this, but the interpretation I am using for satisfying |
I agree that |
No, julia> isless([0, 1], [0.5, 0.5])
true
julia> isless([0.5, 0.5], [1, 0])
true
julia> isless([0.1, 0.9], [0.11, 0.89])
true
julia> isless([0.1, 0.9], [0.1, 0.91])
true |
No, we would not want a bounding box, |
Agreed completely. Let me clarify, I meant my proposal for |
E.g., with DomainSets one would define support(d::Dirichlet) = VectorUnitSimplex{eltype(d)}(length(d)) |
But that is not how |
Thats exactly what the corners of the smallest interval set containing the support is |
That means that the |
No, in the case of Dirichlet it is not. If we sort all elements in its support, i.e., the probability simplex, in lexicographical order, then |
DomainSets uses E.g., the |
Except that Lebesgue on the unit simplex and the unit cube are mutually singular, so you cannot just define the density |
@devmotion I follow you now! So, how would you like to proceed. It seems that this type of definition for I could do something like the following, or use IntervalSets/DomainSets for the output
|
where |
Let's add the more general bounding box in a separate PR. |
Ok, do you want me to finalize this PR, or close it in favor of a separate boundingbox PR? |
Finalize! |
Tests pass on my end and docs look clean now. |
|
||
Return the maximum of the support of `d`. | ||
""" | ||
maximum(d::Distribution) |
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 am not familiar with this idiom. What does it mean?
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 wasn't either, its from #1319 (comment)
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.
and #1319 (comment)
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!
@devmotion you approved it & the CI checks pass - want to merge it, too? : ) |
This PR adds
minimum
,maximum
,extrema
forAbstractMvNormal
andProduct
. The definition extends that currently used for univariate distributions, i.e.minimum
andmaximum
returns the min/max of the support for each dimension.This extends a common interface between Univariate distributions and as subset of MV distributions for querying the bounds of the support for upstream applications such as DiffEqUncertainty, where quadrature is solved over the support.