std_dev::regression::derived

Function power

source
pub fn power<E: LinearEstimator>(
    predictors: &mut [f64],
    outcomes: &mut [f64],
    estimator: &E,
) -> PowerCoefficients
Available on crate feature regression only.
Expand description

Fits a curve with the equation y = a * x^b (optionally with an additional subtractive term if any outcome is < 1 and an additive to the x if any predictor is < 1).

Also sometimes called “growth”.

§Panics

Panics if either x or y don’t have the length len. len must be greater than 2.

§Derivation

y=b * x^a

lg(y) = lg(b * x^a) lg(y) = lg(b) + a(lg x)

Transform: y => lg (y), x => lg(x)

When values found, take 10^b to get b and a is a