PHP code example of pointybeard / helpers-statistics-slidingaverage

1. Go to this page and download the library: Download pointybeard/helpers-statistics-slidingaverage 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/ */

    

pointybeard / helpers-statistics-slidingaverage example snippets




ointybeard\Helpers\Statistics\SlidingAverage;

$average = new SlidingAverage\SlidingAverage(20, 0);

do {

    // Do some work here
    $value = rand(0, 100);

    // Push some value into the ring buffer, e.g. time elapsed etc
    $average->push($value);

    echo "\rAverage is: " . $average->sample();
    usleep(70000);

} while(true);