Closed twiecki closed 2 years ago
@ricardoV94 Thanks, edited the above. If you have time, perhaps you could write a short list of steps of what to do to port them. (Unless you want to take these on yourself :)).
This PR illustrates well with a single distribution refactoring I think: https://github.com/pymc-devs/pymc3/pull/4615/files. What is needed is:
RV op
by inheriting from aesara RandomVariable
, porting the code in the old random
method to the rng_fn
classmethod
of the new RandomVariable
. RandomVariable
to the rv_op
field in the respective PyMC3 distribution.__init__
to the new dist
classmethod
logp
and logcdf
to expect arguments in this order: value, arg1, arg2, ... argn
test_distributions.py
test_distributions_random.py
as seen here, and remove old BaseTestCase
in that file.Importantly, if there are multiple parametrizations, one will have to be set as the default in the dist
classmethod
in step 3. This will be the one that the RandomVariable
is defined in terms of. If the random methods and logp/logcdf methods use different parametrizations, they will have to be converted to the ones that the RandomVariable
is defined in terms of in step 3, and converted back to the logp
and logcdf
methods in step 4.
More details can be found here: https://github.com/pymc-devs/pymc3/issues/4518#issuecomment-806236360
I would like to help on this issue. Should we create a separate PR for each distribution?
No you can do multiple in one go, just mark the ones you are working on.
On Wed, May 12, 2021, 13:28 Farhan Reynaldo @.***> wrote:
I would like to help on this issue. Should we create a separate PR for each distribution?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/pymc-devs/pymc3/issues/4686#issuecomment-839695709, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFETGDPFKEEQJRE2ZEKOVDTNJQ4ZANCNFSM44X5P5LQ .
I would like to help on this issue. Should we create a separate PR for each distribution?
That might be too much. You can group a couple (or all) in a single PR.
I would suggest you start with the univariate distributions. The multivariate ones will probably be a bit more tricky.
@brandonwillard what should we do with the flat
and halfFlat
distributions that don't have a random method? Should we create a RandomVariable
whose rng_fn
returns the same ValueError("Cannot sample from Flat distribution")
as in V3
?
@brandonwillard what should we do with the
flat
andhalfFlat
distributions that don't have a random method? Should we create aRandomVariable
whoserng_fn
returns the sameValueError("Cannot sample from Flat distribution")
as inV3
?
Yeah, we can do that for now.
Was LKJCholeskyCov
refactored? I don't see it in the list
@alexandorra I added it to the list.
opened this issue on May 12, 2021
Holy cow, can't believe we finally got them all! 🥳
There are still various continuous distributions missing for
v4
that need to get ported. Here is an example of how to do this port for whereaesara
does not provide aRandomVariable
(which is all of the currently missing ones): https://github.com/pymc-devs/pymc3/blob/v4/pymc3/distributions/continuous.py#L2648Here is a list of the missing continuous ones:
Flat
#4723HalfFlat
#4723TruncatedNormal
#4711Wald
#4711Kumaraswamy
#4706Laplace
#4691AsymmetricLaplace
#4746StudentT
#4694Pareto
https://github.com/pymc-devs/pymc3/pull/4691ChiSquared
#4695HalfStudentT
#4746ExGaussian
#4746SkewNormal
#4705Rice
#4705LogitNormal
#4703Interpolated
#4746Moyal
#4704DensityDist
#5026And the missing multivariate ones:
MvStudentT
#4731DirichletMultinomial
#4758Wishart
https://github.com/pymc-devs/pymc3/pull/4777LKJCorr
#5382LKJCholeskyCov
#5382MatrixNormal
#4777KroneckerNormal
#4774CAR
#4596Would be very important to add these to get an alpha out.
See @ricardoV94's comment below for a step-by-step guide on how to port a distribution.