class pymc.Censored(name, *args, rng=None, dims=None, initval=None, observed=None, total_size=None, transform=UNSET, default_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}\]

Univariate distribution which will be censored. This distribution must have a logcdf method implemented for sampling.


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

lowerfloat or None

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

upperfloat or None

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


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().


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)


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

Creates a tensor variable corresponding to the cls distribution.