Skip to content

transforms.ordered doesn't apply to samples found with .random() #4213

Closed
@EdAyers

Description

@EdAyers

Please provide a minimal, self-contained, and reproducible example.

Modified version of example given at https://docs.pymc.io/api/distributions/discrete.html?highlight=ordered#pymc3.distributions.discrete.OrderedLogistic

import pymc3 as pm
import numpy as np
with pm.Model() as model:
    cutpoints = pm.Normal("cutpoints", mu=[-1,1], sigma=10, shape=2,
                          transform=pm.distributions.transforms.ordered, testval=np.asarray([.5, .9]))
    for i in range(10):
        c = cutpoints.random()
        print(c, c[0] < c[1])

Please provide the full traceback.

[-1.78978722  2.24029602] True
[ 7.27625258 -9.98526886] False
[-2.3456616   6.17737276] True
[-12.42092868  -2.94677656] True
[0.8365788  9.45209727] True
[-12.07594385  13.38498445] True
[ 4.94704378 17.77777978] True
[7.0118523  7.82261754] True
[ -3.387632   -10.23571222] False
[ 8.48851098 -3.25975408] False

Expected result: c[0] is always < c[1]

However the full demo given at the URL works fine. So I guess that one of the members of the Transform subclass has a bug in it?
Or maybe I misunderstood the API and when you call X.random() you are supposed to see the sample before the transform?
It seems quite likely this is a bug but apologies if this is actually correct behaviour.

Here is another one where someone is sampling an ordered pair but no output.
#3680

Versions and main components

  • PyMC3 Version: 3.9.3
  • Theano Version: 1.0.5
  • Python Version: 3.8.6
  • Operating system: Arch Linux
  • How did you install PyMC3: pip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions