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

Ordered bijector #7

Closed
junpenglao opened this issue Mar 30, 2018 · 7 comments · Fixed by tensorflow/tensorflow#18647
Closed

Ordered bijector #7

junpenglao opened this issue Mar 30, 2018 · 7 comments · Fixed by tensorflow/tensorflow#18647

Comments

@junpenglao
Copy link
Contributor

Constrain a vector/tensor being ordered along a specific dimension.

@srvasude
Copy link
Member

Hi!
Just to clarify, given a vector [X1, ... X_n] this would be writing the order statistics X_(1), ... X_(n) in order, correct?

If I am understanding this correctly, this wouldn't be a bijection. Consider the vectors [2.1, 3., 4.], [3., 2.1, 4.] and [4., 3., 2.1]. All of them would map to [2.1, 3., 4.].

However, bijectors has been extended to a certain subclass of non-bijective transformations (e.g. there is an AbsoluteValue bijector), so I could see the same treatment being done here (because given a vector of length k, every preimage set is of cardinality k, up to multiplicity.).

@srvasude
Copy link
Member

I misspoke and meant to say the preimage set is of size k! (every permutation).

@bob-carpenter
Copy link

To generate an ordered vector y from an unconstrained vector x is set y[1] = x[1], and then y[2] = y[1] + exp(x[2]), and so on. The log Jacobian is just sum(x[2: ]). Then if you set y ~ normal(0, 1), you'll indeed see the order statistics just as if you'd taken an unconstrained vector x ~ normal(0, 1) and sorted.

@mrosenkranz
Copy link

So I understand this is for the bijective "ordered transform" described in section 35.5 of the Stan reference manual v. 2.17.1? I might give this a try, though it might take a while.

@junpenglao
Copy link
Contributor Author

@mrosenkranz I actually just sent a PR implementing the ordered transformation tensorflow/tensorflow#18647.
And yes that's the same as in Stan (manual 2.17.1) and PyMC3 (WIP PR).

@srvasude
Copy link
Member

Thanks for the clarification Bob and Junpeng! Given that order statistics is also something that can be a valid bijector, I was a little confused :).

@junpenglao, currently reviewing your PR. Apologies for any delays, since I am still familiarizing myself with the github review tools.

@ricardoV94
Copy link

To generate an ordered vector y from an unconstrained vector x is set y[1] = x[1], and then y[2] = y[1] + exp(x[2]), and so on. The log Jacobian is just sum(x[2: ]). Then if you set y ~ normal(0, 1), you'll indeed see the order statistics just as if you'd taken an unconstrained vector x ~ normal(0, 1) and sorted.

Perhaps obvious, but this is only true for IID after the ~

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

Successfully merging a pull request may close this issue.

6 participants