{"id":33018426,"url":"https://github.com/powder96/numbers.php","last_synced_at":"2025-11-16T14:00:37.257Z","repository":{"id":6119313,"uuid":"7347341","full_name":"powder96/numbers.php","owner":"powder96","description":"Advanced Mathematics Library for PHP (port of Numbers.js)","archived":false,"fork":true,"pushed_at":"2016-04-14T18:10:29.000Z","size":886,"stargazers_count":158,"open_issues_count":5,"forks_count":18,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-10-29T05:56:59.366Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"numbers/numbers.js","license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/powder96.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-12-27T23:19:48.000Z","updated_at":"2025-06-25T07:31:48.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/powder96/numbers.php","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/powder96/numbers.php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/powder96%2Fnumbers.php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/powder96%2Fnumbers.php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/powder96%2Fnumbers.php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/powder96%2Fnumbers.php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/powder96","download_url":"https://codeload.github.com/powder96/numbers.php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/powder96%2Fnumbers.php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":284719042,"owners_count":27052182,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-16T02:00:05.974Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-11-13T18:00:39.568Z","updated_at":"2025-11-16T14:00:37.251Z","avatar_url":"https://github.com/powder96.png","language":"PHP","funding_links":[],"categories":["数字","数字 Numbers","Text and Numbers","数字( Numbers )","Numbers"],"sub_categories":[],"readme":"# Numbers.php\n[Numbers.php](https://github.com/powder96/numbers.php/) - an advanced mathematics toolkit for PHP \u003e= 5.3. It is a port of [Numbers.js](https://github.com/sjkaliski/numbers.js/) - same toolkit for JavaScript.\n\nThere is a version of Numbers.php which supports PHP 5.2, but it is no longer developed: https://github.com/powder96/numbers.php/archive/fd946ea8742ba46789dc2a38cc6c1f93a7512e6d.zip\n\n## Description\n\nNumbers.php provides a comprehensive set of mathematical tools that currently are not offered in PHP. These tools include:\n\n* Basic calculations\n* Calculus\n* Matrix Operations\n* Prime Numbers\n* Statistics\n* More...\n\nA few things to note before using: PHP, like many languages, does not necessarily manage floating points as well as we'd all like it to. For example, if adding decimals, the addition tool won't return the exact value. This is an unfortunate error. Precautions have been made to account for this. After including numbers, you can set an error bound. Anything in this will be considered an \"acceptable outcome.\"\n\nThe primary uses cases are calculations and data analysis on the server side. For client side operations, please use [Numbers.js](https://github.com/sjkaliski/numbers.js/).\n\n## How to use\n\nNumbers is pretty straightforward to use.\n\nFor example, if we wanted to estimate the integral of sin(x) from -2 to 4, we could:\n\nUse riemann integrals (with 200 subdivisions)\n```php\nuse NumbersPHP\\Calculus;\nuse NumbersPHP\\Matrix;\nuse NumbersPHP\\Statistic;\nuse NumbersPHP\\Prime;\n\nCalculus::riemann('sin', -2, 4, 200);\n```\n\nOr use adaptive simpson quadrature (with epsilon 0.0001)\n\n```php\nCalculus::adaptiveSimpson('sin', -2, 4, 0.0001);\n```\n\nUser-defined functions can be used too:\n\n```php\nfunction myFunc($x) {\n  return 2 * pow($x, 2) + 1;\n}\nCalculus::riemann('myFunc', -2, 4, 200);\n\nCalculus::adaptiveSimpson(create_function('$x', 'return 2 * pow($x, 2) + 1;'), -2, 4, 0.0001);\n```\n\nNow say we wanted to run some matrix calculations:\n\nWe can add two matrices\n\n```php\n$matrix1 = array(array(0, 1, 2),\n\t\t\t\t array(3, 4, 5));\n$matrix2 = array(array( 6,  7,  8),\n\t\t\t\t array( 9, 10, 11));\nMatrix::addition($matrix1, $matrix2);\n```\n\nWe can transpose a matrix\n\n```php\nMatrix::transpose($array);\n```\n\nNumbers also includes some basic prime number analysis.  We can check if a number is prime:\n\n```php\n//basic check\nPrime::simple($number);\n\n// Miller�Rabin primality test\nPrime::millerRabin($number);\n```\n\nThe statistics tools include mean, median, mode, standard deviation, random sample generator, correlation, confidence intervals, t-test, chi-square, and more.\n\n```php\nStatistic::mean($array);\nStatistic::median($array);\nStatistic::mode($array);\nStatistic::standardDev($array);\nStatistic::randomSample($lower, $upper, $n);\nStatistic::correlation($array1, $array2);\n```\n\n## Test\n\nDownload and install these things:\n\n* [PHP \u003e= 5.3](http://php.net/)\n* [Composer PHAR](http://getcomposer.org/composer.phar)\n* [PHPUnit PHAR](http://pear.phpunit.de/get/phpunit.phar)\n\nRun in the command prompt:\n\n```cmd\n\tphp composer.phar install\n\tphp phpunit.phar --configuration phpunit.xml.dist\n```\n\nIf you are going to run tests multiple times and you are using Microsoft(R) Windows(TM), you can use the batch file /test.cmd. Do not forget to set the path to PHP, Composer, and PHPUnit in the beginnig of that file. \n\n## Authors\n\n### Numbers.js\n\n* Steve Kaliski - [sjkaliski](http://twitter.com/sjkaliski)\n* David Byrd - [davidbyrd11](http://twitter.com/davidbyrd11)\n* Ethan Resnick - [studip101](http://twitter.com/studip101)\n* Ethan - [altercation](https://github.com/altercation)\n* Hrishikesh Paranjape - [hrishikeshparanjape](https://github.com/hrishikeshparanjape)\n* Greg Leppert - [leppert](https://github.com/leppert)\n* Lars-Magnus Skog - [ralphtheninja](https://github.com/ralphtheninja)\n* Tim Wood - [codearachnid](https://github.com/codearachnid)\n* Miles McCrocklin - [milroc](https://github.com/milroc)\n* Nate Kohari - [nkohari](https://github.com/nkohari)\n* Eric LaForce - [elaforc](https://github.com/elaforc)\n* Kartik Talwar - [KartikTalwar](https://github.com/KartikTalwar)\n* [btmills](https://github.com/btmills)\n* swair shah - [swairshah](https://github.com/swairshah)\n* Jason Hutchinson - [Zikes](https://github.com/Zikes)\n* Philip I. Thomas - [philipithomas](https://github.com/philipithomas)\n* Brandon Benvie - [Benvie](https://github.com/Benvie)\n* Larry Battle - [LarryBattle](https://github.com/LarryBattle)\n* [kmcgrane](https://github.com/kmcgrane)\n\n### Numbers.php\n\n* [powder96](https://github.com/powder96/)\n* [geopal-solutions](https://github.com/geopal-solutions/)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpowder96%2Fnumbers.php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpowder96%2Fnumbers.php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpowder96%2Fnumbers.php/lists"}