MetalogFeasibilityChecker

class MetalogFeasibilityChecker(val uniformStep: Double = DEFAULT_UNIFORM_STEP, val tailDecades: Int = DEFAULT_TAIL_DECADES)(source)

Checks whether a metalog coefficient vector defines a valid quantile function.

A metalog is a valid distribution exactly when its quantile function is strictly increasing, that is, when the quantile derivative is positive throughout the open interval from zero to one. This is a property of the fitted coefficients rather than a constraint that can be imposed on them in advance, so it has to be verified after the fact. Nothing about a data set guarantees that a least squares fit to it will be feasible.

For two and three terms the condition is available in closed form and the companion functions should be preferred. For four or more terms no closed form exists and the derivative is scanned on a grid. A uniform grid alone under-resolves the tails, which is where violations tend to hide, so the grid combines uniform interior spacing with geometric refinement approaching each endpoint.

Feasibility of the underlying metalog is necessary and sufficient for every member of the family, because each boundedness transform contributes a strictly positive density factor.

Parameters

uniformStep

the spacing of the uniform portion of the grid, which must be in (0, 0.5)

tailDecades

how many powers of ten of refinement to add approaching each endpoint

Constructors

Link copied to clipboard
constructor(uniformStep: Double = DEFAULT_UNIFORM_STEP, tailDecades: Int = DEFAULT_TAIL_DECADES)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

How many probabilities the grid contains.

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard

Scans the grid and reports the smallest quantile derivative found along with where it occurred. Unlike isFeasible, this always performs the scan, so it can be used to inspect how much margin a feasible fit has.

Link copied to clipboard

A defensive copy of the probabilities at which the derivative is evaluated.

Link copied to clipboard
fun isFeasible(coefficients: DoubleArray): Boolean

True when the supplied coefficients define a valid quantile function. Two- and three-term coefficient vectors take the exact closed-form route.