
Calculating Mathematical Statistics in PHP
1use HiFolksStatisticsStat;
2
3Stat::mean([1, 2, 3, 4, 4]); // 2.8
4Stat::mean([–1.0, 2.5, 3.25, 5.75]); // 2.625
5
6// The central tendency or typical value of the data
7// using the product of the values.
8Stat::geometricMean([54, 24, 36], 1); // 36.0
9
10Stat::median([1, 3, 5]); // 3
11Stat::median([1, 3, 5, 7]); // 4
12
13Stat::firstQuartile([
14 98,90,70,18,92,92,55,83,45,95,88
15]); // 55.0
16
17Stat::thirdQuartile([
18 98,90,70,18,92,92,55,83,45,95,88
19]); // 92.0
20
21$fruits = [
22 ‘?’, ‘?’, ‘?’, ‘?’,‘?’,‘?’,‘?’,‘?’,‘?’
23];
24$freqTable = Freq::frequencies($fruits);
25print_r($freqTable);
26
27/*
28Array
29(
30 [?] => 3
31 [?] => 5
32 [?] => 1
33)
34*/
Credit: Source link