distributions.local_pareto_to_piecewise()
Converts the local Pareto distribution with local alpha alpha(x)
Usage
distributions.local_pareto_to_piecewise(
t, alpha, rel_tolerance=0.0001, stop_survival=1e-09, stop_at=Ellipsis
)above t to a piecewise Pareto that matches its survival function exactly at the thresholds and within rel_tolerance between them.
Parameters
t: float-
Threshold;
P(X > x) = 1below it. alpha: callable-
alpha(x) -> float, finite and non-negative, positive where the conversion stops. rel_tolerance: float = 1e-4stop_survival: float = 1e-9-
Stop once the survival function falls below this.
stop_at: float = inf- Stop at this amount.
Returns
tuple of (PiecewisePareto, float, float)- The approximation, the largest relative error found, and where the approximated range ends (the last alpha continues above it).
Examples
>>> import math
>>> from prospicio.distributions import local_pareto_to_piecewise
>>> pp, err, end = local_pareto_to_piecewise(1000.0, lambda x: 1.5 + 0.3 * math.log(x / 1000.0))
>>> err <= 1e-4True