pangolin.interface.Interface.cdf

Contents

pangolin.interface.Interface.cdf#

Interface.cdf(fun)[source]#

A combinator building CDFs, accepting an RV-like evaluation value.

Calling cdf(fun)(value, *args, **kwargs) coerces value to an RV and supplies all remaining arguments unchanged to fun. No broadcasting is added. Otherwise, the contract is the same as pangolin.functional.cdf.

Return type:

Callable[…, RV]

Parameters:

fun (Callable[[P], RV]) – Function creating one random RV.

Returns:

cdf_fun – Function taking an RV-like evaluation value followed by fun’s arguments, and returning a scalar CDF RV.

Notes

Newly coerced evaluation values use this interface; existing RVs are preserved. The result retains the interface of the random RV returned by fun.

Examples

>>> from pangolin import interface as pi
>>> normal_cdf = pi.cdf(pi.normal)
>>> normal_cdf(0.0, 0.0, 1.0)
RV(CDF(Normal()), RV(Constant(0.)), RV(Constant(0.)), RV(Constant(1.)))

The supplied function can include ordinary parameter calculations:

>>> def normal_with_log_scale(mean, log_scale):
...     return pi.normal(mean, pi.exp(log_scale))
>>> model_cdf = pi.cdf(normal_with_log_scale)
>>> model_cdf(0.0, 0.0, 0.0)
RV(CDF(Normal()), RV(Constant(0.)), RV(Constant(0.)), RV(Exp(), RV(Constant(0.))))