MetalogPlottingPositions

Turns raw observations into the cumulative distribution function data that a metalog is parameterized by.

A metalog is fitted to points on a cumulative distribution function rather than to observations directly, so each sorted observation is paired with a plotting position. The convention used here places the i-th of m sorted values at a probability of one half less than i, divided by m, which keeps every probability strictly inside the unit interval, as the basis functions require.

For a large sample the data is instead resampled onto a fixed probability grid. That bounds the height of the design matrix without discarding the tails, since the grid is refined approaching each endpoint, which is where a metalog's shape flexibility is most needed and where evenly spaced probabilities carry the least information.

Properties

Link copied to clipboard

Above this many observations the sample is resampled onto a fixed probability grid rather than used point for point.

Link copied to clipboard
const val DEFAULT_STEP: Double = 0.01

The spacing of the interior of the resampling grid.

Functions

Link copied to clipboard
fun cdfData(data: DoubleArray, resampleThreshold: Int = DEFAULT_RESAMPLE_THRESHOLD, step: Double = DEFAULT_STEP): Pair<DoubleArray, DoubleArray>

Pairs the supplied observations with cumulative probabilities, returning the values first and the probabilities second. The values come back sorted, since a cumulative distribution function is being described.

Link copied to clipboard
fun positions(sampleSize: Int): DoubleArray

The plotting positions for a sample of the given size.

Link copied to clipboard
fun resamplingGrid(step: Double = DEFAULT_STEP): DoubleArray

The probability grid used when resampling: evenly spaced through the interior, and refined by a further order of magnitude approaching each endpoint.