pymc4 icon indicating copy to clipboard operation
pymc4 copied to clipboard

Implement transforms and logp for "MvNormal", "Pareto", "Triangular" distributions

Open canyon289 opened this issue 7 years ago • 8 comments

Distributions are currently raising exception when logp is called. Transform need to be implemented on all.

https://github.com/pymc-devs/pymc4/blob/master/pymc4/tests/test_random_variables.py#L95

canyon289 avatar Mar 04 '19 15:03 canyon289

This should probably be an issue with TFP. Do you they have e.g. a stick-breaking bijector?

twiecki avatar Mar 04 '19 15:03 twiecki

It doesn't look like it from the docs below but this definitely needs to be an issue with in pymc4 as well because we have code that needs to change, independent of what TFP is or isnt. :)

https://www.tensorflow.org/probability/api_docs/python/tfp/bijectors/Bijector

canyon289 avatar Mar 04 '19 15:03 canyon289

Stick breaking bijector issue in TFP for reference https://github.com/tensorflow/probability/issues/6

canyon289 avatar Mar 04 '19 17:03 canyon289

FWIW, we also do have a SoftmaxCentered bijector, which also constrains/unconstrains the same regions (R^n -> unit simplex in R^{n+1}), but can lead to different optimization landscapes / HMC trajectories than the Stick breaking one.

Are there any other transforms you will need?

srvasude avatar Mar 04 '19 18:03 srvasude

I think we can definitely move ahead with the SoftmaxCentered bijector for now.

Nice to have would also be a

  • OrderedTransform: https://github.com/pymc-devs/pymc3/blob/c73f97da71657ab7d9f4bb77a205b5bd49471657/pymc3/distributions/transforms.py#L298
  • Cholesky: https://github.com/pymc-devs/pymc3/blob/c73f97da71657ab7d9f4bb77a205b5bd49471657/pymc3/distributions/transforms.py#L436 (I'm not sure we need this one as the implementation in TFP might handle this differently).
  • Circular: https://github.com/pymc-devs/pymc3/blob/c73f97da71657ab7d9f4bb77a205b5bd49471657/pymc3/distributions/transforms.py#L416

twiecki avatar Mar 05 '19 09:03 twiecki

Ordered should be here: https://www.tensorflow.org/probability/api_docs/python/tfp/bijectors/Ordered

For Cholesky, I'm not sure what is exactly going on here, but we do have https://www.tensorflow.org/probability/api_docs/python/tfp/bijectors/TransformDiagonal which should help.

Circular is something we are missing, and we can definitely add that.

srvasude avatar Mar 05 '19 09:03 srvasude

I'm not sure about Circular; it's not injective, and not even finitely non-injective like Square/Abs.

How is it used by pymc?

brianwa84 avatar Mar 05 '19 21:03 brianwa84

This should be true for (0, 1) -> S^1 (or more generally for an interval (a, b), there's an injective map to S^1, which scales (a, b) and then applies (cos(.), sin(.))

srvasude avatar Mar 05 '19 21:03 srvasude