markrogoyski/math-php
Math Library for PHP. Features descriptive statistics and regressions; Continuous and discrete probability distributions; Linear algebra with matrices and vectors, Numerical analysis; special mathematical functions; Algebra
v2.13.0
8.0M downloads/mo
#1774 most downloaded on Packagist
markrogoyski/math-php
What this package is like to depend on
Last release 10 months ago
24 Oct 2025
Release timing varies
gaps range from 2 weeks to 10 months
Most releases are documented
notes for 90 of 140 stable releases
Nothing withdrawn
no release was ever pulled
10 years old
140 releases · first in 2016
2 releases in the last 12 months
see the full history below
Release timeline
140 releases · Apr 2016 to Oct 2025Releases
latest 60 of 140-
v2.13.024 Oct 2025Release notes
Open source →New Features
- Matrix
columnAddScalar - Matrix
columnSubtract - Matrix
columnSubtractScalar - Matrix
columnDivide
Bug Fixes
- Algebra::quadratic returns empty array when a=0 and b=0 (Previously would divide by zero)
- Trigonometry::unitCircle division by zero error for single-point.
- SampleData\People
getShoeSizehas a typo and wasgetShowSize. This has been fixed. - Fixed calculation in Probability\Distribution\Discrete\Hypergeometric
cdf. Implementation changed to use sum of PMFs. - Statistics\Correlation
sampleCovariance,populationCorrelationCoefficient,sampleCorrelationCoefficient, throw BadDataException or OutOfBoundsException rather than division by zero for bad input data. - Statistics\Descriptive
coefficientOfVariationwill return NAN if mean is zero. Previously did division by zero. - Fix some typos in Statistics\Distance
hellinger,brayCurtis, andcanberrathat could have resulted in incorrect results. - Fix \Statistics\EffectSize
cohensQbounds check [-1, 1] and throw OutOfBoundsException when outside range, and return INF when r == 1 or -1. - Fix \Statistics\EffectSize boundary edge cases resulting in division by zero for
hedgesG,cohensD, andglassDelta.
Improvements
- Refactor the geometric mean implementation to use a numerically stable log-space calculation
- Refactor ChiSquared pdf to avoid raising 0 to negative exponent which is deprecated
- Refactor LogLogistic pdf and cdf to avoid raising 0 to negative exponent which is deprecated
- Improved implementation of NoncentralT
median - Probability\Distribution\Multivariate\Multinomial uses a higher numerical precision to reject probabilities that don't sum to 1.0
- Rewrote Statistics\Distribution
fractionalRankingto track original indices and use == for tie detection instead ofstrval()grouping, avoiding floating-point comparison bugs. - Statistics\Distribution
cumulativeFrequencyandcumulativeRelativeFrequencynow do a frequency distribution on sorted data, which was the original intent. - Statistics\Divergence
kullbackLeiblerandjensenShannonthrow an exception if there are non-negative probabilities. - Statistics\Distribution
stemAndLeafPlotthrows an exception if there are negative values. - Statistics\Experiment functions throw exceptions when input outside of range.
likelihoodRatioSSreturns infinity for rather than division by zero. - Statistics\Outlier edge cases throw exceptions: Grubbs' having fewer than 3 observations; standard deviation of zero; Support upper/lower as aliases for one sided in
grubbsCriticalValue. - Improved exception message for Functions\Support
checkLimitsto add invalid endpoint character in the exception message
Release notes
Open source →New Features
- Matrix
columnAddScalar - Matrix
columnSubtract - Matrix
columnSubtractScalar - Matrix
columnDivide
Bug Fixes
- Algebra::quadratic returns empty array when a=0 and b=0 (Previously would divide by zero)
- Trigonometry::unitCircle division by zero error for single-point.
- SampleData\People
getShoeSizehas a typo and wasgetShowSize. This has been fixed. - Fixed calculation in Probability\Distribution\Discrete\Hypergeometric
cdf. Implementation changed to use sum of PMFs. - Statistics\Correlation
sampleCovariance,populationCorrelationCoefficient,sampleCorrelationCoefficient, throw BadDataException or OutOfBoundsException rather than division by zero for bad input data. - Statistics\Descriptive
coefficientOfVariationwill return NAN if mean is zero. Previously did division by zero. - Fix some typos in Statistics\Distance
hellinger,brayCurtis, andcanberrathat could have resulted in incorrect results. - Fix \Statistics\EffectSize
cohensQbounds check [-1, 1] and throw OutOfBoundsException when outside range, and return INF when r == 1 or -1. - Fix \Statistics\EffectSize boundary edge cases resulting in division by zero for
hedgesG,cohensD, andglassDelta.
Improvements
- Refactor the geometric mean implementation to use a numerically stable log-space calculation
- Refactor ChiSquared pdf to avoid raising 0 to negative exponent which is deprecated
- Refactor LogLogistic pdf and cdf to avoid raising 0 to negative exponent which is deprecated
- Improved implementation of NoncentralT
median - Probability\Distribution\Multivariate\Multinomial uses a higher numerical precision to reject probabilities that don't sum to 1.0
- Rewrote Statistics\Distribution
fractionalRankingto track original indices and use == for tie detection instead ofstrval()grouping, avoiding floating-point comparison bugs. - Statistics\Distribution
cumulativeFrequencyandcumulativeRelativeFrequencynow do a frequency distribution on sorted data, which was the original intent. - Statistics\Divergence
kullbackLeiblerandjensenShannonthrow an exception if there are non-negative probabilities. - Statistics\Distribution
stemAndLeafPlotthrows an exception if there are negative values. - Statistics\Experiment functions throw exceptions when input outside of range.
likelihoodRatioSSreturns infinity for rather than division by zero. - Statistics\Outlier edge cases throw exceptions: Grubbs' having fewer than 3 observations; standard deviation of zero; Support upper/lower as aliases for one sided in
grubbsCriticalValue. - Improved exception message for Functions\Support
checkLimitsto add invalid endpoint character in the exception message
- Matrix
-
v2.12.018 Oct 2025Release notes
Open source →New Features
- Matrix Hessenberg decomposition
- New special functions
- Bessel functions
- Airy functions
- Legendre polynomials
- Chebyshev polynomials
- Hermite polynomials
- Laguerre polynomials
Bug Fixes
- Fixed issue 487 in t-test with data with no variance: throws proper exception
- Fixed issue with Set
isProperSubsetwhere it didn't take into account identical sets
Improvements
- Numerical precision improvements to numerous special functions
- Documentation improvements and fixes
Release notes
Open source →New Features
- Matrix Hessenberg decomposition
- New special functions
- Bessel functions
- Airy functions
- Legendre polynomials
- Chebyshev polynomials
- Hermite polynomials
- Laguerre polynomials
Bug Fixes
- Fixed issue 487 in t-test with data with no variance: throws proper exception
- Fixed issue with Set
isProperSubsetwhere it didn't take into account identical sets - Fixed exception message for Functions\Support::checkLimits where invalid endpoint character did not display the endpoint character in the exception message
Improvements
- Numerical precision improvements to numerous special functions
- Documentation improvements and fixes
-
v2.11.026 Jan 2025 -
v2.10.017 Apr 2024 -
v2.9.003 Mar 2024Release notes
Open source →New Features
- Distance
chebyshev
Improvements
- Internal build CI/CD improvements
Release notes
Open source →New Features
- Distance
chebyshev
Improvements
- Internal build CI/CD improvements
- Distance
-
v2.8.119 May 2023Release notes
Open source →Improvements
- Internal improvements to improve conformance with static analysis tools
Release notes
Open source →Improvements
- Internal improvements to improve conformance with static analysis tools
-
v2.8.007 May 2023Release notes
Open source →New Features
- Matrix
rowAddVector - Matrix
columnAddVector
Improvements
- Better error handling and exception message in
Sequence\NonIntenger::hyperharmonic - Internal code improvements to conform to static analysis checks
Backwards Incompatible Changes
- Helper method names changed (public abstract methods but not part of published interface)
NumericalDifferentiation::isTargetInPointschanged toassertTargetInPointsNumericalDifferentiation::isSpacingConstantchanged toassertSpacingConstant
Release notes
Open source →New Features
- Matrix
rowAddVector - Matrix
columnAddVector
Improvements
- Better error handling and exception message in
Sequence\NonIntenger::hyperharmonic - Internal code improvements to conform to static analysis checks
Backwards Incompatible Changes
- Helper method names changed (public abstract methods but not part of published interface)
NumericalDifferentiation::isTargetInPointschanged toassertTargetInPointsNumericalDifferentiation::isSpacingConstantchanged toassertSpacingConstant
- Matrix
-
v2.7.031 Dec 2022Release notes
Open source →Improvements
- Improved algorithm for
regularizedIncompleteBeta: Addresses issue 458 - Issue 456: Improved PHPDoc blocks: Changed "number" to "int|float"
- Added PHP 8.2 for CI test target
Release notes
Open source →Improvements
- Improved algorithm for
regularizedIncompleteBeta: Addresses issue 458 - Issue 456: Improved PHPDoc blocks: Changed "number" to "int|float"
- Added PHP 8.2 for CI test target
- Improved algorithm for
-
v2.6.010 Apr 2022Release notes
Open source →v2.6.0 - 2022-04-10
Improvements
Average::truncatedMeanbehavior at 50% trim made consistent- PHP 8.1 compatibility improvements
Backwards Incompatible Changes
Average::truncatedMeanthrows exception if trim percent greater than 50% rather than error or unpredictable results.
Release notes
Open source →Improvements
Average::truncatedMeanbehavior at 50% trim made consistent- PHP 8.1 compatibility improvements
Backwards Incompatible Changes
Average::truncatedMeanthrows exception if trim percent greater than 50% rather than error or unpredictable results. -
v2.5.022 Nov 2021Release notes
Open source →New Features
- Special function
logbeta - Special function
logGamma - Special function
logGammaCorr - Special function
stirlingError
Improvements
- Improvements in StudentT continuous distribution
- Improvements in special function
gamma - Improvements in special function
beta
Bug Fixes
- Issue 393 (regularizedIncompleteBeta NAN)
- Issue 429 (Linear regression CI division by zero)
Release notes
Open source →New Features
- Special function
logbeta - Special function
logGamma - Special function
logGammaCorr - Special function
stirlingError
Improvements
- Improvements in StudentT continuous distribution
- Improvements in special function
gamma - Improvements in special function
beta
Bug Fixes
- Issue 393 (regularizedIncompleteBeta NAN)
- Issue 429 (Linear regression CI division by zero)
- Special function
-
v2.4.028 Jul 2021Release notes
Open source →New Features
- Complex Exponential (
exp) - Complex Exponentiation (
pow) - Zipf's Law Discrete Distribution
- Generalized harmonic non-integer sequence
Improvements
- Fixed Complex
polarFormto compute the right values - Fixed
hyperharnomicnon-integer sequence. Previously was computing the wrong thing - Fixed how
ArbitraryIntergerhandlespowof negative exponents
Backwards Incompatible Changes
- Complex
polarFormnow returns an array rather than a Complex number, as the Complex return was incorrect - Interface to
hyperharmonicnon-integer sequence changed due to previous implementation being incorrect
- Complex Exponential (
-
v2.3.014 Jul 2021Release notes
Open source →New Features
- Matrix SVD (Singular Value Decomposition)
- Polynomial companion matrix
-
v2.2.011 Jul 2021Release notes
Open source →New Features
- PLS (Partial Least Squares Regression)
Improvements
- Add custom
__debugInfotoNumericMatrix
-
v2.1.007 Jul 2021 -
v2.0.009 May 2021Release notes
Open source →New Features
- Matrix Improvements
walkmethod to map a function to all values without mutation or returning a valueMatrixFactorycreates more matrix typesMatrixFactory::createNumericto createNumericMatrixtypesMatrixFactory::createFromRowVectorMatrixFactory::createFromColumnVector- Internal
ObjectMatriximprovements- Add
trace - Add
scalarMultiply
- Add
- Add initial
ComplexMatrix
- Sample data People
Improvements
- Bug fixes
- Issue 414 fixed - PCA/Eigenvalue convergence
- Issue 413 fixed - matrix solve with singular matrix using RREF
- Matrix Improvements
-
v1.11.009 May 2021Release notes
Open source →Improvements
- Bugfix (Issue 413): Matrix solve with singular matrix using RREF
- Bugfix (Issue 414): PCA/Eigenvalue convergence
-
v1.10.019 Dec 2020 -
v1.9.013 Dec 2020Release notes
Open source →New Features
- Vector min and max
- Arithmetic isqrt (integer square root)
Improvements
- Remove Travis CI (Moved CI to Github Actions in v1.8.0 release)
- Rearrange non-code files
-
v1.8.011 Dec 2020Release notes
Open source →Improvements
- Improve permutations algorithm to be more efficient and more numerically stable
- Qualify PHP function names with root namespace
- Move CI to Github Actions
-
v1.7.015 Nov 2020Release notes
Open source →New Features
- Algebra linear equation of one variable
- Rational number inverse
- Rational number pow
Improvements
- Improve combinations algorithm to be more efficient and more numerically stable
- Internal Matrix class reorganization
-
v1.6.022 Oct 2020Release notes
Open source →New Features
- Special function regularized lower incomplete gamma
- Cereal sample data set
Improvements
- Define boundary condition for lower incomplete gamma function
-
v1.5.013 Oct 2020Release notes
Open source →New Features
- Matrix LU solve
- Matrix QR solve
Improvements
- Bugfix (Issue 386) Matrix solve improvements
- Matrix solve has optional method parameter to force a solve method
- Bugfix ArbitraryInteger multiplication sign not taken into account
-
v1.4.003 Oct 2020Release notes
Open source →New Features
- Multivariate Regular Grid Interpolation
- Jensen-Shannon Distance
- Canberra Distance
- Search Sorted
- Search ArgMax
- Search NanArgMax
- Search ArgMin
- Search NanArgMin
- Search NonZero
Improvements
- Divergence factored out of Distance into new Divergence class
Backwards Incompatible Changes
- Legacy Distance divergences marked as deprecated (To be removed in v2.0.0)
-
v1.3.025 Aug 2020Release notes
Open source →New Features
- LinearAlgebra\Vector
- Angle between two vectors
- L¹ distance of two vectors
- L² distance of two vectors
- Minkowski distance of two vectors
- Statistics\Distance
- Minkowski distance
- Euclidean distance (L² distance)
- Manhattan distance (Taxicab geometry, L¹ distance, etc.)
- Cosine distance
- Cosine similarity
- LinearAlgebra\Vector
-
v1.2.025 Jul 2020Release notes
Open source →New Features
- Ranking
- Ordinal ranking
- Standard competition ranking
- Modified competition ranking
- Fractional ranking
Improvements
- (Issue 380) Fixed Spearman's Rho calculation when there are rank ties
- Ranking
-
v1.1.020 Apr 2020Release notes
Open source →New Features
- Arithmetic modulo
Improvements
- Improved matrix multiplication performance using cache-oblivious algorithm optimization
-
v1.0.014 Apr 2020 -
v0.62.006 Apr 2020 -
v0.61.022 Mar 2020 -
v0.60.027 Feb 2020 -
v0.59.019 Feb 2020Release notes
Open source →New Features
- Add population and sample kurtosis
- Changed default kurtosis algorithm to the more common population kurtosis
- kurtosis now takes an optional parameter to set the kurtosis type algorithm
-
v0.58.007 Feb 2020Release notes
Open source →Improvements
- Changed default skewness algorithm to the more common sample skewness
- skewness now takes an optional parameter to set the skewness type algorithm
- Improvements to skewness algorithms
-
v0.57.007 Jan 2020Release notes
Open source →New Features
- Number\Rational basic getters
- getWholePart
- getNumerator
- getDenominator
- Set Theory n-ary Cartesian product
Improvements
- Data direction control for Matrix meanDeviation and covarianceMatrix
- Algebra factors performance improvement
- Number\Rational basic getters
-
v0.56.004 Dec 2019Release notes
Open source →New Features
- Number Theory
- isDeficientNumber
- isAbundantNumber
- aliquotSum
- radical
- totient
- cototient
- reducedTotient
- mobius
- isSquarefree
- isRefactorableNumber
- isSphenicNumber
- numberOfDivisors
- sumOfDivisors
Improvements
- Optimization of prime factorization algorithm
- Number Theory
-
v0.55.019 Nov 2019Release notes
Open source →New Features
- Arbitrary length integers
Improvements
- Factorial optimization
-
v0.54.013 Oct 2019Release notes
Open source →New Features
- Matrix isNilpotent
- Matrix isRectangularDiagonal
- Matrix mapRows
- MathPHP logo
Improvements
- MatrixFactory random matrix custom lower and upper bounds for random number
- PSR-12 style compliance
- Bugfix: powerIteration random failure - Issue 346
-
v0.53.010 Sep 2019Release notes
Open source →New Features
- Matrix QR decomposition using Householder reflections
- Matrix Householder transformation
- MatrixFactory random matrix
- MatrixFactory givens rotation matrix
- Matrix isIdempotent
- Matrix Eigenvalue power iteration
- Matrix Eigenvalue jacobi method
- Arithmetic root (nᵗʰ root)
- Vector arithmetic multiply and divide
- Vector Iterator interface
Improvements
- Internal improvements to Matrix
- Matrix decompositions returned as objects
- Matrix Cholesky decomposition provides L transpose
-
v0.52.011 Jul 2019 -
v0.51.005 Jun 2019Release notes
Open source →New Features
- Matrix rowSums
- Matrix columnSums
- Matrix rowMeans
- Matrix columnMeans
- Matrix isNormal
- MatrixFactory diagonal matrix creation method
- MatrixFactory vandermonde matrix creation method
Improvements
- Set custom Matrix tolerances
- Various internal improvements
Backwards Incompatible Changes
- Remove Matrix sampleMeans (use rowMeans or columnMeans instead)
- MatrixFactory create method only works with 2d arrays. 1d arrays no longer work. (use diagonal and vandermonde factory methods instead)
- Statistics methods throw exceptions instead of returning null on bad input
- Change return type of LagrangePolynomial to Polynomial
-
v0.50.023 Apr 2019Release notes
Open source →New Features
- Matrix isOrthogonal
- Matrix isEqual
- Harmonic sequence
- Hyperharmonic sequence
- Map\Single reciprocal
Improvements
- Support methods for almost equal
- Matrix getDiagonalElements works for non-square matrices
- Use more efficient algorithm in Matrix isSymmetric
- Use more efficient algorithm in Matrix isSkewSymmetric
Backwards Incompatible Changes
- Statistics methods throw exceptions instead of returning null on bad input
-
v0.49.023 Feb 2019Release notes
Open source →New Features
- Matrix augmentAbove
- Matrix augmentLeft
Improvements
- Object matrix multiplication
-
v0.48.016 Dec 2018Release notes
Open source →New Features
- Matrix submatrix
- Mahalanobis distance
- Bernoulli distribution mean, median, mode and variance
- Binomial distribution mean and variance
- Geometric distribution mean, median, mode and variance
- Hypergeometric distribution mode and variance
- NegativeBinomial (Pascal) distribution CDF, mean, mode and variance
- Poisson distribution mean, median, mode and variance
- Discrete Uniform distribution variance
Improvements
- Binomial distribution PMF uses more numerically stable multiplication method
- Fix potential divide by zero in TheilSen regression
Backwards Incompatible Changes
- Multinomial distribution moved from Discrete to Multivariate namespace
-
v0.47.021 Nov 2018Release notes
Open source →New Features
- Beta distribution median, mode, variance
- Cauchy distribution variance
- ChiSquared distribution mode, variance
- Exponential distribution median, mode, variance
- F distribution mode, variance
- Gamma distribution median, mode, variance
- Laplace distribution mode, variance
- Logistic distribution mode, vaiance
- LogLogistic distribution median, mode, variance
- LogNormal distribution mode, variance
- Normal distribution mode, variance
- StandardNormal distribution mode, variance
- StudentT distribution mode, variance
- Uniform distribution median, mode, variance
- Weibull distribution median, mode
Improvements
- Normal distribution rand algorithm changed to Box–Muller transform
-
v0.46.028 Oct 2018Release notes
Open source →New Features
- NumberTheory isPerfectNumber
- Sequence perfectNumber
Improvements
- Improve README documentation for continuous distributions
- Updates to build tools
- General improvements
-
v0.45.025 Sep 2018Release notes
Open source →Improvements
- Add Beta distribution inverse quantile function
- Improvements to Weibull distribution
- Improvements to Cauchy distribution
- Improvements to Laplace distribution
- Improvements to Logistic distribution
- Improvements to LogNormal distribution
- Improvements to Normal distribution
- Improvements to Pareto distribution
- Improvements to Algebra cubic/quartic complex root handling
-
v0.44.030 Aug 2018Release notes
Open source →Improvements
- [Issue 271] Improvements to documentation
- [Issue 269] Add closed-form inverse function for Exponential distribution
-
v0.43.021 May 2018 -
v0.42.010 May 2018Release notes
Open source →New Features
- Weighted mean
- Weighted sample variance
- Weighted covariance
- Weighted correlation coefficient
Improvements
- Minor code improvements
-
v0.41.023 Apr 2018Release notes
Open source →New Features
- Arithmetic almostEqual
Improvements
- Statistics\Average::mode improved to work with non-integer values
- Various minor code improvements
-
v0.40.022 Mar 2018Release notes
Open source →New Features
- Simpler interface for Significance
tTestfor one and two samples
Improvements
- T test for two samples uses more robust Welch test
- Improvements to Normal and Standard Normal continuous distributions
- General improvements to continuous distributions
- Simpler interface for Significance
-
v0.39.027 Feb 2018Release notes
Open source →Improvements
- Upgrade unit testing framework to PHPUnit 6
- Update unit tests for PHPUnit 6 compatibility
- Add PHP 7.2 to continuous integration tests
-
v0.38.011 Dec 2017Release notes
Open source →Improvements
- Percentile reimplemented to use linear interpolation between closest ranks method - Second variant, C = 1
- General code improvements
- Better error and exception handling
-
v0.37.024 Oct 2017Release notes
Open source →Improvements
- Change probability distributions to be objects instead of static methods
Backwards Incompatible Changes
- Change probability distributions to be objects instead of static methods
-
v0.36.027 Sep 2017Release notes
Open source →New Features
- Rational number
- Gamma distribution mean
Improvements
- Add .gitignore file
-
v0.35.020 Aug 2017Release notes
Open source →New Features
- Matrix isTridiagonal
- Matrix isUpperHessenberg
- Matrix isLowerHessenberg
- Matrix getSuperdiagonalElements
- Matrix getSubdiagonalElements
Improvements
-
v0.34.012 Aug 2017 -
v0.33.004 Aug 2017 -
v0.32.025 Jul 2017Release notes
Open source →New Features
- Matrix Crout decomposition
- Categorical discrete distribution
-
v0.31.030 Jun 2017 -
v0.30.011 Jun 2017Release notes
Open source →New Features
- Dirichlet multivariate distribution
- Gamma distribution
- Initial eigenvalue matrix method
- Initial eigenvector matrix method
- Confidence ellipse
Improvements
- Internal Bitwise addition