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

Adding bijectors for OrderStatistic and JointOrderStatistics #258

Open
sethaxen opened this issue May 23, 2023 · 1 comment
Open

Adding bijectors for OrderStatistic and JointOrderStatistics #258

sethaxen opened this issue May 23, 2023 · 1 comment

Comments

@sethaxen
Copy link
Member

JuliaStats/Distributions.jl#1668 added distributions for sample order statistics" OrderStatistic and JointOrderStatistics.

OrderStatistic has the same constraints as the distribution it wraps and should get the same bijector.

bijector(d::OrderStatistic) = bijector(d.dist)

The support of JointOrderStatistics is the sorted vectors whose elements are in the support of the wrapped distribution. An example bijector could be:

function bijector(d::JointOrderStatistics)
    dist = d.dist
    binner = bijector(dist)
    bunsort = inverse(OrderedBijector())
    # assume all upper bounded distributions have monotonically decreasing bijectors.
    scale = (binner isa Union{typeof(identity),Truncated} || islowerbounded(dist)) ? 1 : -1
    return bunsort  Scale(scale)  binner
end

To set scale correctly, we need to know if the bijector being used is monotonically increasing or decreasing. While we can hardcode a check for all bijectors defined in this package, to support user-implemented bijectors, we would seem to need an isdecreasing(::Bijector) API function.

Note that with a correct bijector defined for JointOrderStatistics, in a PPL like Turing, a user could use JointOrderStatistics(Exponential(), 100) to infer a sorted vector of parameters from the same distribution, instead of Bijectors.ordered(filldist(Exponential(), 100)), which as noted in #220 (comment) does the wrong thing (and now raises an error).

@torfjelde
Copy link
Member

I'm personally happy to include a isdecreasing function or something similar. This will also be useful for some additional functionality, e.g. support for univariate distributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants