PHP code example of webit / downsampling
1. Go to this page and download the library: Download webit/downsampling 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/ */
webit / downsampling example snippets
use Webit\DownSampling\DownSampler\LargestTriangleThreeBucketsDownSampler;
$data = array();
for ($i=0; $i < 500; $i++) {
$data[] = [$i, mt_rand(0, 200)];
}
$sampler = new LargestTriangleThreeBucketsDownSampler();
$sampled = $sampler->sampleDown($data, 100);
echo count($sampled); // displays 100