PHP code example of balsama / benford

1. Go to this page and download the library: Download balsama/benford library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

balsama / benford example snippets


$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],
//  ]

$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.