Limok Palantaemon Limok Palantaemon - 2 months ago 21
Python Question

How to create a SkewNormal stochastic in pymc3?

How would one use

DensityDist
to create a SkewNormal distribution for pymc3? There are several dead links to github pages explaining how to create custom Stochastic that are floating around.

exp
is implemented in theano, but I don't think the Normal Cumulative distribution or the
erf
functions are.

I presume I couldn't just use something like:

F = DensityDist('F', lambda value: pymc.skew_normal_like(value, um, std, a), shape = N)


Where I import the skew_normal_like distribution from pymc2?

Answer

The erf function is implemented in Theano. Try this

skn = pm.DensityDist('skn', lambda value: tt.log(1 + tt.erf(((value - mu) * tt.sqrt(tau) * alpha)/tt.sqrt(2))) + (-tau * (value - mu)**2 + tt.log(tau / np.pi / 2.)) / 2. )

where:

tau = sd**-2

Update:

The SkewNormal is now included as part of the ready-to-use PyMC3's distributions.