Censored#
- 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}\]- Parameters:
- distunnamed_distribution
Univariate distribution 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,int, array_like orNone Lower (left) censoring point. If None the distribution will not be left censored
- upper
float,int, array_like orNone 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
Deterministicclip().Examples
Censoring with upper & lower points set to +/-1 .. code-block:: python
- 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)
Partial censoring of normal distributions achienved by passing +/-inf censor points. Examples of 4 censor conditions: uncensored (-inf, inf), upper censored (-inf, 1), lower censored (-1, inf), and both censored (-1, 1) .. code-block:: python
- with pm.Model():
normal_dist = pm.Normal.dist(mu=0.0, sigma=1.0) partially_censored_normals = pm.Censored(“partially_censored_normals”, normal_dist, lower=[-np.inf, -np.inf, -1, -1], upper=[np.inf, 1, np.inf, 1], shape=(4,))
Methods
Censored.dist(dist[, lower, upper])Create a tensor variable corresponding to the cls distribution.