Powerful modern math library for PHP: Features descriptive statistics and regressions; Continuous and discrete probability distributions; Linear algebra with ma
Powerful modern math library for PHP: Features descriptive statistics and regressions; Continuous and discrete probability distributions; Linear algebra with ma
Add the library to your composer.json file in your project:
{
"require": {
"markrogoyski/math-php": "2.*"
}
}Use composer to install the library:
$ php composer.phar installComposer will install MathPHP inside your vendor folder. Then you can add the following to your .php files to use the library with Autoloading.
require_once __DIR__ . '/vendor/autoload.php';Alternatively, use composer on the command line to require and install MathPHP:
$ php composer.phar require markrogoyski/math-php:2.* Note: For PHP 7.0 and 7.1, use v1.0 (markrogoyski/math-php:1.*)
……………………………………………………………………………use MathPHP\Sequence\NonInteger;
$n = 4; // Number of elements in the sequence
// Harmonic sequence
$harmonic = NonInteger::harmonic($n);
// [1, 3/2, 11/6, 25/12] - Indexed from 1
// Generalized harmonic sequence
$m = 2; // exponent
$generalized = NonInteger::generalizedHarmonic($n, $m);
// [1, 5 / 4, 49 / 36, 205 / 144] - Indexed from 1
// Hyperharmonic sequence
$r = 2; // depth of recursion
$hyperharmonic = NonInteger::hyperharmonic($n, $r);
// [1, 5/2, 26/6, 77/12] - Indexed from 1……………………use MathPHP\Statistics\Divergence;
// Probability distributions
$X = [0.2, 0.5, 0.3];
$Y = [0.1, 0.4, 0.5];
// Divergences
$Dkl⟮X‖Y⟯ = Divergence::kullbackLeibler($X, $Y);
$JSD⟮X‖Y⟯ = Divergence::jensenShannon($X, $Y);………………………use MathPHP\Trigonometry;
$n = 9;
$points = Trigonometry::unitCircle($n); // Produce n number of points along the unit circleBeyond 100% code coverage!
MathPHP has thousands of unit tests testing individual functions directly with numerous data inputs to achieve 100% test coverage. MathPHP unit tests also test mathematical axioms which indirectly test the same functions in multiple different ways ensuring that those math properties all work out according to the axioms.
$ cd tests
$ phpunitMathPHP conforms to the following standards:
MathPHP is licensed under the MIT License.
No open issues yet, or sync has not completed.