Limok Palantaemon - 8 months ago 75

Python Question

How would one use

`DensityDist`

`exp`

`erf`

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.

Source (Stackoverflow)