wells5609/decimal

Library built atop the Decimal and Datastructures PHP extensions

dev-master 2019-03-17 02:54 UTC

This package is auto-updated.

Last update: 2024-04-17 14:12:17 UTC


README

Library built atop the ds and decimal PHP extensions.

Namespace: Xpl\Decimal

Dependencies:

  • wells5609\datetime
  • ds extension
  • decimal extension
  • php >= 7.3

Vector (class)

A strict implementation of Ds\Sequence that restricts values to Decimal\Decimal instances.

Has additional methods for doing common math operations - most are self-explanatory:

min(): Decimal

max(): Decimal

sum(): Decimal

mean(): Decimal

prod(): Decimal

delta(): Vector

Returns a vector containing the difference between each value (i.e. $this[i] - $this[i-1]).

rdelta(): Vector

Returns a vector containing the difference between each value as a percent (i.e. ($this[i] - $this[i-1]) / $this[i-1])

diff(Vector $y): Vector

Returns a vector containing the difference between each value in $this and $y (i.e. $this[i] - $y[i])

var(): Decimal

Variance

covar(): Decimal

Covariance

stdev(): Decimal

Standard deviation

coefficientOfVariation(): Decimal

Coefficient of variation (aka relative standard deviation)

indexOfDispersion(): Decimal

Index of dispersion (aka relative variance)

correl(Vector $y): Decimal

Pearson's correlation coefficient (aka Pearson-product-moment correlation coefficient, "Pearson's r")

varp(): Decimal

Variance, treating the data as a population

stdevp(): Decimal

Standard deviation, treating the data as a population

centralMoment(int $k, bool $sample = true): Decimal

Central moment of the power $k

skewness(): Decimal

regressionSumOfSquares($ybar): Decimal

residualSumOfSquares(Vector $y): Decimal

totalSumOfSquares(Vector $y): Decimal