risk.iman_conover()

Reorders each component’s draws to a target correlation (Iman-Conover).

Usage

risk.iman_conover(
    pd,
    correlation,
    seed,
)

Every component keeps exactly its own draws; only their pairing across simulations changes. The correlation of the result’s normal scores is close to correlation, and Spearman’s rho close to (6 / pi) asin(correlation / 2).

Parameters

pd: PredictiveDistribution
correlation: list of list of float

One row and column per component.

seed: int

Returns

PredictiveDistribution

Examples

>>> from prospicio.distributions import PredictiveDistribution
>>> from prospicio.risk import iman_conover
>>> rows = [[float(i), float((i * 7919) % 1000)] for i in range(1000)]
>>> pd = PredictiveDistribution(["lob"], [(0,), (1,)], rows)
>>> joined = iman_conover(pd, [[1.0, 0.7], [0.7, 1.0]], seed=3)
>>> sorted(joined.marginal((1,)).draws) == sorted(pd.marginal((1,)).draws)

True