Competence of step methods

Hello,

I noticed that the Metropolis competence() method returns Competence.INCOMPATIBLE for continous random variables, as in this snippet:

    @staticmethod
    def competence(var):
        if var.dtype in pm.discrete_types:
            return Competence.COMPATIBLE
        return Competence.INCOMPATIBLE

Similarly, the slice step methods has:

    @staticmethod
    def competence(var):
        if var.dtype in continuous_types:
            if not var.shape:
                return Competence.PREFERRED
            return Competence.COMPATIBLE
        return Competence.INCOMPATIBLE

which returns INCOMPATIBLE unless the type is continuous, while the slice sampler is supposed to work with discrete random variables too.

Is it a problem if we use metropolis to update continous random variables or slice to update discrete random variables? I’d say no, as, e.g., metropolis has been suggested in many contexts (as in theano_op user defined random variables). But, how safe is that? Did I get something wrong?

Hi @mcavallaro, you can use Metropolis to sample continuous RVs - not sure about the slice sampler tho. Currently we are setting ‘COMPATIBLE’ only for discrete RVs in Metropolis, because only a few discrete RVs are assigned with Metropolis automatically.

Thanks @junpenglao. Anyway, using the slice class on discrete random variables doesn’t raise any error despite the incompatible flag. Probably it’s worth claryfing this aspect (e.g., in the documentation) as both the slice sampler and the metropolis-hasting in theory work with discrete variables.

1 Like

Good point. PR welcomes :wink:

I’d love to do that, but didn’t really understood how that is meant to work…