https://github.com/oefenweb/php-statistics
Statistics library for PHP
https://github.com/oefenweb/php-statistics
php statistics
Last synced: 11 months ago
JSON representation
Statistics library for PHP
- Host: GitHub
- URL: https://github.com/oefenweb/php-statistics
- Owner: Oefenweb
- License: mit
- Created: 2015-05-31T18:06:12.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2022-03-23T10:43:40.000Z (about 4 years ago)
- Last Synced: 2024-11-06T20:50:28.542Z (over 1 year ago)
- Topics: php, statistics
- Language: PHP
- Size: 44.9 KB
- Stars: 32
- Watchers: 4
- Forks: 10
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# php-statistics
[](https://travis-ci.org/Oefenweb/php-statistics)
[](https://travis-ci.org/Oefenweb/php-statistics)
[](https://codecov.io/gh/Oefenweb/php-statistics)
[](https://packagist.org/packages/oefenweb/statistics)
[](https://codeclimate.com/github/Oefenweb/php-statistics)
[](https://scrutinizer-ci.com/g/Oefenweb/php-statistics/?branch=master)
Statistics library for PHP.
## Requirements
* PHP 7.2.0 or greater.
## Usage
### Sum
```php
use Oefenweb\Statistics\Statistics;
Statistics::sum([1, 2, 3]); // 6
```
### Minimum
```php
use Oefenweb\Statistics\Statistics;
Statistics::min([1, 2, 3]); // 1
```
### Maximum
```php
use Oefenweb\Statistics\Statistics;
Statistics::max([1, 2, 3]); // 3
```
### Mean
```php
use Oefenweb\Statistics\Statistics;
Statistics::mean([1, 2, 3]); // 2
```
### Frequency
```php
use Oefenweb\Statistics\Statistics;
Statistics::frequency([1, 2, 3, 3, 3]); // [1 => 1, 2 => 1, 3 => 3]
```
### Mode
```php
use Oefenweb\Statistics\Statistics;
Statistics::mode([1, 2, 2, 3]); // 2
```
### Variance (sample and population)
```php
use Oefenweb\Statistics\Statistics;
Statistics::variance([1, 2, 3]); // 1
Statistics::variance([1, 2, 3], false); // 0.66666666666667
```
### Standard deviation (sample and population)
```php
use Oefenweb\Statistics\Statistics;
Statistics::standardDeviation([1, 2, 3]); // 1.0
Statistics::standardDeviation([1, 2, 3], false); // 0.81649658092773
```
### Range
```php
use Oefenweb\Statistics\Statistics;
Statistics::range([4, 6, 10, 15, 18]); // 14
```