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.
- lowertensor_like of
float, optional Lower (left) censoring point, broadcast against
dist. An entry of-np.infleaves that entry uncensored. Default is-np.inf.- uppertensor_like of
float, optional Upper (right) censoring point, broadcast against
dist. An entry ofnp.infleaves that entry uncensored. Default isnp.inf.
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
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)
Censoring bounds can differ per entry:
with pm.Model(): normal_dist = pm.Normal.dist(mu=0.0, sigma=1.0, shape=2) censored_normal = pm.Censored( "censored_normal", normal_dist, lower=[-1.0, -np.inf], upper=[1.0, 0.0] )
Methods
Censored.dist(dist[, lower, upper])Create a tensor variable corresponding to the cls distribution.