balsama/benford

本福德定律分布和偏差计算器。

1.0.0-alpha1 2020-03-29 00:41 UTC

This package is auto-updated.

Last update: 2024-08-29 05:29:13 UTC


README

本福德定律表明,在许多自然出现的数字集合中,首位有效数字很可能较小。具体来说,数字1作为首位有效数字出现大约30%的时间,而数字9作为首位有效数字出现的时间不到5%。同样的百分比可以扩展到第二和第三位数字。(第三位数字之后,所有数字出现的可能性大致相同。)

本福德定律

用法

包含到您的项目中

$ composer require balsama/benford

计算数字[0-9]在数字集合的前三位中出现的百分比。

$set = [123, 1, 707, 2];
$distibution = Balsama\Benford::getBenfordDistrubution($set);
print_r($distibution);
//  [
//      [1] => [0, 50, 25, 0, 0, 0, 0, 25, 0, 0],
//      [2] => [50, 0, 50, 0, 0, 0, 0, 0, 0, 0],
//      [3] => [0, 0, 0, 50, 0, 0, 0, 50, 0, 0],
//  ]

计算与Benford预测的偏差。

$set = [...]; // A large set of numbers spanning multiple orders of magnitude for best results.
$deviation = Balsama\Benford::getBenfordDeviationScoreFromSet($set);
print $deviation;
// A float. 20 is a good number (meaning likely to be a naturally occurring number set. Use your own data sets to
// determine what a good or bad score is for your purposes.