Skip to content

Transformations

fenbux.affine(d: AbstractDistribution, loc: ArrayLike = 0.0, scale: ArrayLike = 1.0) -> PyTree

Affine transformation of a distribution y = loc + scale * x

Parameters:

Name Type Description Default
d AbstractDistribution

A distribution object.

required
loc ArrayLike

loc parameter of the affine transformation.

0.0
scale ArrayLike

scale parameter of the affine transformation.

1.0

Examples:

>>> from fenbux import affine, logpdf
>>> from fenbux.univariate import Normal
>>> dist = Normal(0.0, 1.0)
>>> aff_dist = affine(dist, 0.0, 1.0)
>>> logpdf(aff_dist, 0.0)

fenbux.truncate(d: AbstractDistribution, lower: ArrayLike = -inf, upper: ArrayLike = inf) -> PyTree

Truncate a distribution to a given interval.

Parameters:

Name Type Description Default
d AbstractDistribution

A distribution object.

required
lower ArrayLike

Lower bound of the truncated distribution.

-inf
upper ArrayLike

Upper bound of the truncated distribution.

inf

Examples:

>>> from fenbux import truncate, logpdf
>>> from fenbux.univariate import Normal
>>> dist = Normal(0.0, 1.0)
>>> truncate(dist, -1.0, 1.0)
>>> logpdf(dist, -2.0)

fenbux.censor(d: AbstractDistribution, lower: ArrayLike = -inf, upper: ArrayLike = inf) -> PyTree

Censor a distribution to a given interval.

Parameters:

Name Type Description Default
d AbstractDistribution

A distribution object.

required
lower ArrayLike

Lower bound of the censored distribution.

-inf
upper ArrayLike

Upper bound of the censored distribution.

inf

Examples:

>>> from fenbux import censor, logpdf
>>> from fenbux.univariate import Normal
>>> dist = Normal(0.0, 1.0)
>>> censor(dist, -1.0, 1.0)
>>> logpdf(dist, -2.0)