wells5609 / decimal
Library built atop the Decimal and Datastructures PHP extensions
Requires
- php: >=7.3.2
- ext-ds: ~1.0
- php-decimal/php-decimal: ~1.0
- php-ds/php-ds: ~1.0
- wells5609/datetime: ~1.0
This package is auto-updated.
Last update: 2025-01-17 15:45:01 UTC
README
Library built atop the ds
and decimal
PHP extensions.
Namespace: Xpl\Decimal
Dependencies:
- wells5609\datetime
ds
extensiondecimal
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