Interesting, that works in more cases than I expected.

It only works if alpha is a number, not if alpha is a tensor. If alpha is a
tensor it will always return the tensor part, not the inf. So the resulting
theano computation will give the wrong values when alpha < 0.


On Tue, Apr 8, 2014 at 7:25 AM, Thomas Wiecki <notifications@github.com>wrote:

> In pymc/distributions/continuous.py:
>
> > +    alpha : float
> > +        Shape parameter (alpha>0)
> > +    m : float
> > +        Scale parameter (m>0)
> > +
> > +    .. note::
> > +       - :math:`E(x)=\frac{\alpha m}{\alpha-1} if \alpha > 1`
> > +       - :math:`Var(x)=\frac{m^2 \alpha}{(\alpha-1)^2(\alpha-2)
> } if \alpha > 2`
> > +
> > +    """
> > +    def __init__(self, alpha, m, *args, **kwargs):
> > +        super(Pareto, self).__init__(*args, **kwargs)
> > +        self.alpha = alpha
> > +        self.m = m
> > +        # Mean and variance return inf when parameter constraint not satisfied
> > +        self.mean = (alpha>1) * alpha * m / (alpha - 1.) or inf
>
> how about:
>
> self.mean = alpha * m / (alpha - 1.) if (alpha>1) else inf
>
> --
> Reply to this email directly or view it on GitHub<https://github.com/pymc-devs/pymc/pull/526/files#r11391845>
> .
>