pymc.Censored#

class pymc.Censored(name, *args, rng=None, dims=None, initval=None, observed=None, total_size=None, transform=UNSET, **kwargs)[source]#

Censored distribution

The pdf of a censored distribution is

\[\begin{split}\begin{cases} 0 & \text{for } x < lower, \\ \text{CDF}(lower, dist) & \text{for } x = lower, \\ \text{PDF}(x, dist) & \text{for } lower < x < upper, \\ 1-\text{CDF}(upper, dist) & \text {for} x = upper, \\ 0 & \text{for } x > upper, \end{cases}\end{split}\]
Parameters
dist: unnamed distribution

Univariate distribution created via the .dist() API, which will be censored. This distribution must have a logcdf method implemented for sampling.

Warning

dist will be cloned, rendering it independent of the one passed as input.

lower: float or None

Lower (left) censoring point. If None the distribution will not be left censored

upper: float or None

Upper (right) censoring point. If None, the distribution will not be right censored.

Warning

Continuous censored distributions should only be used as likelihoods. Continuous censored distributions are a form of discrete-continuous mixture and as such cannot be sampled properly without a custom step sampler. If you wish to sample such a distribution, you can add the latent uncensored distribution to the model and then wrap it in a Deterministic clip().

Examples

with pm.Model():
    normal_dist = pm.Normal.dist(mu=0.0, sigma=1.0)
    censored_normal = pm.Censored("censored_normal", normal_dist, lower=-1, upper=1)

Methods

Censored.__init__(*args, **kwargs)

Censored.dist(dist, lower, upper, **kwargs)

Creates a tensor variable corresponding to the cls distribution.

Censored.rv_op(dist[, lower, upper, size])