src/Malenki/Math/Stats/NormalDistribution.php
public function samples($amount)
    {

        if (!is_numeric($amount) || $amount < 1) {
            throw new \InvalidArgumentException('Amount of samples must be greater or equal to one');
        }

        $arr = array();

        for ($i = 1; $i <= $amount; $i++) {
            $r = new Random();
            $float_u = $r->get();
            $float_v = $r->get();

            $double_x = $this->float_sigma * sqrt(-2 * log($float_u)) * cos(2 * pi() * $float_v) + $this->float_mu;

            if ($this->int_precision) {
                $arr[] = round($double_x, $this->int_precision);
            } else {
                $arr[] = $double_x;
            }
        }

        return $arr;
    }
public function samples($amount)
    {

        if (!is_numeric($amount) || $amount < 1) {
            throw new \InvalidArgumentException('Amount of samples must be greater or equal to one');
        }

        $arr = array();

        for ($i = 1; $i <= $amount; $i++) {
            $r = new Random();
            $float_u = $r->get();
            $float_v = $r->get();

            $double_x = $this->float_sigma * sqrt(-2 * log($float_u)) * cos(2 * pi() * $float_v) + $this->float_mu;

            if ($this->int_precision) {
                $arr[] = round($double_x, $this->int_precision);
            } else {
                $arr[] = $double_x;
            }
        }

        return $arr;
    }
public function samples ( $ amount ) { if ( ! is_numeric ( $ amount ) || $ amount < 1 ) { throw new \ InvalidArgumentException ( 'Amount of samples must be greater or equal to one' ) ; } $ arr = array ( ) ; for ( $ i = 1 ; $ i <= $ amount ; $ i ++ ) { $ r = new Random ( ) ; $ float_u = $ r -> get ( ) ; $ float_v = $ r -> get ( ) ; $ double_x = $ this -> float_sigma * sqrt ( - 2 * log ( $ float_u ) ) * cos ( 2 * pi ( ) * $ float_v ) + $ this -> float_mu ; if ( $ this -> int_precision ) { $ arr [ ] = round ( $ double_x , $ this -> int_precision ) ; } else { $ arr [ ] = $ double_x ; } } return $ arr ; }
Simulates samples following normal distribution

@see NormalDistribution::precision()
@throw \InvalidArgumentException If amount is not greater than zero
@param  integer $amount
@access public
@return array
Simulates samples following normal distribution