PHP code example of happyr / normal-distribution-bundle

1. Go to this page and download the library: Download happyr/normal-distribution-bundle 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/ */

    

happyr / normal-distribution-bundle example snippets




namespace Acme\DemoBundle\Controller;

use Happyr\NormalDistributionBundle\Service\DistributionManager;

class DemoController
{
    public function testController()
    {
        $manager = $this->get(DistributionManager::class);

        $foo = array(8,6,2,6,4,2,3,6,4,8,2,7);
        $bar = $manager->createValueFrequencyArray($foo);
        /*
            $bar should now look like this:
            $bar = (
                2 => 3,
                3 => 1,
                4 => 2,
                6 => 3,
                7 => 1,
                8 => 2
            )
        */
        $summary = $manager->addDistribution('test_id', $bar);

        //get the percentile for a value
        $percentile = $manager->getPercentile('test_id', 3.5);

        $this->get('doctrine.orm.entity_manager')->flush();

        /* ... */
    }
}




// in AppKernel::registerBundles()
$bundles = array(
    // ...
    new Happyr\NormalDistributionBundle\HappyrNormalDistributionBundle(),
    // ...
);