Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
roberto-butti committed Jan 7, 2022
1 parent 8c17c94 commit 5dc3db2
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,61 @@ echo "Mode : " . $stat->getMode() . PHP_EOL;
// Mode : 5
```

### Calculate Frequencies Table

Statistics packages has some methods for generating Frequencies Table:
- getFrequencies(): a frequency is the number of times a value of the data occurs;
- getRelativeFrequencies(): a relative frequency is the ratio (fraction or proportion) of the number of times a value of the data occurs in the set of all outcomes to the total number of outcomes;
- getCumulativeFrequences(): is the accumulation of the previous relative frequencies.;
- getCumulativeRelativeFrequencies(): is the accumulation of the previous relative ratio.



```php
use HiFolks\Statistics\Statistics;

$s = Statistics::make(
[98, 90, 70,18,92,92,55,83,45,95,88,76]
);
$a = $s->getFrequencies();
print_r($a);
/*
Array
(
[18] => 1
[45] => 1
[55] => 1
[70] => 1
[76] => 1
[83] => 1
[88] => 1
[90] => 1
[92] => 2
[95] => 1
[98] => 1
)
*/

$a = $s->getRelativeFrequencies();
print_r($a);
/*
Array
(
[18] => 8.3333333333333
[45] => 8.3333333333333
[55] => 8.3333333333333
[70] => 8.3333333333333
[76] => 8.3333333333333
[83] => 8.3333333333333
[88] => 8.3333333333333
[90] => 8.3333333333333
[92] => 16.666666666667
[95] => 8.3333333333333
[98] => 8.3333333333333
)
*/

```
## Testing

```bash
Expand Down

0 comments on commit 5dc3db2

Please sign in to comment.