Calculating Mathematical Statistics in PHP
Hi-Folks/statistics is a PHP package that provides functions for calculating mathematical statistics of numeric data. This package includes functions that can calculate things like mean, median, quartile calculations, and specialized calculations like geometric mean:
1use HiFolks\Statistics\Stat; 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]); // 311Stat::median([1, 3, 5, 7]); // 412 13Stat::firstQuartile([14 98,90,70,18,92,92,55,83,45,95,8815]); // 55.016 17Stat::thirdQuartile([18 98,90,70,18,92,92,55,83,45,95,8819]); // 92.020 21$fruits = [22 '🍈', '🍈', '🍈', '🍉','🍉','🍉','🍉','🍉','🍌'23];24$freqTable = Freq::frequencies($fruits);25print_r($freqTable);26 27/*28Array29(30 [🍈] => 331 [🍉] => 532 [🍌] => 133)34*/
The above is just a sample of the various functions provided in this package. The readme has good documentation and examples of using all of them. You can learn more about this package, get full installation instructions, and view the source code on GitHub.
0 comments:
Post a Comment
Thanks