Search code examples
pymc3

pymc3: Beta Distribution sd vs sigma


I'm getting to know the lovely pymc3 library, and want to make sure I understand correctly. The signature for a Beta Distribution is class pymc3.distributions.continuous.Beta(alpha=None, beta=None, mu=None, sigma=None, sd=None, *args, **kwargs). In practice, when using this in a model, you need to make the first argument be a string name for the distribution, but I don't see that mentioned here. More importantly, the documentation seems to state what all of the parameters are for except for 'sd'.

Parameters
alpha: float
alpha > 0.

beta: float
beta > 0.

mu: float
Alternative mean (0 < mu < 1).

sigma: float
Alternative standard deviation (0 < sigma < sqrt(mu * (1 - mu))).

It seems that I can define a beta distribution using alpha and beta, mu and sigma, or mu and sd. When I try to define a beta distribution using alpha and mu I am told ValueError: Incompatible parameterization. Either use alpha and beta, or mu and sigma to specify distribution. This also seems to ignore sd.

My primary question is, what is the difference between sigma and sd? I see very similar results when using them interchangeably.

Thanks for any insights.


Solution

  • Looking at the source, one can see that the sd parameter is an alias for sigma. Note that if you provide both, sd will take precedence.

    As for naming, this is inherited from the Distribution class, which is the only one in the hierarchy that actually has a __new__() method defined. It's this base class that picks off that argument, and the rest get passed along to the Beta.__init__() method.