public static function gaussian(int $m, int $n) : self
    {
        if ($m < 1 or $n < 1) {
            throw new InvalidArgumentException('Dimensionality must be'
                . ' greater than 0 on all axes.');
        }

        $a = $extras = [];

        for ($i = 0; $i < $m; $i++) {
            $row = [];
            
            if (!empty($extras)) {
                $row[] = array_pop($extras);
            }

            for ($j = count($row); $j < $n; $j += 2) {
                $r1 = rand(0, PHP_INT_MAX) / PHP_INT_MAX;
                $r2 = rand(0, PHP_INT_MAX) / PHP_INT_MAX;

                $r = sqrt(-2. * log($r1));

                $row[] = $r * sin($r2 * self::TWO_PI);
                $row[] = $r * cos($r2 * self::TWO_PI);
            }

            if (count($row) > $n) {
                $extras[] = array_pop($row);
            }

            $a[] = $row;
        }

        return self::quick($a);
    }
public static function gaussian(int $m, int $n) : self
    {
        if ($m < 1 or $n < 1) {
            throw new InvalidArgumentException('Dimensionality must be'
                . ' greater than 0 on all axes.');
        }

        $a = $extras = [];

        for ($i = 0; $i < $m; $i++) {
            $row = [];
            
            if (!empty($extras)) {
                $row[] = array_pop($extras);
            }

            for ($j = count($row); $j < $n; $j += 2) {
                $r1 = rand(0, PHP_INT_MAX) / PHP_INT_MAX;
                $r2 = rand(0, PHP_INT_MAX) / PHP_INT_MAX;

                $r = sqrt(-2. * log($r1));

                $row[] = $r * sin($r2 * self::TWO_PI);
                $row[] = $r * cos($r2 * self::TWO_PI);
            }

            if (count($row) > $n) {
                $extras[] = array_pop($row);
            }

            $a[] = $row;
        }

        return self::quick($a);
    }
public static function gaussian ( int $ m , int $ n ) : self { if ( $ m < 1 or $ n < 1 ) { throw new InvalidArgumentException ( 'Dimensionality must be' . ' greater than 0 on all axes.' ) ; } $ a = $ extras = [ ] ; for ( $ i = 0 ; $ i < $ m ; $ i ++ ) { $ row = [ ] ; if ( ! empty ( $ extras ) ) { $ row [ ] = array_pop ( $ extras ) ; } for ( $ j = count ( $ row ) ; $ j < $ n ; $ j += 2 ) { $ r1 = rand ( 0 , PHP_INT_MAX ) / PHP_INT_MAX ; $ r2 = rand ( 0 , PHP_INT_MAX ) / PHP_INT_MAX ; $ r = sqrt ( - 2. * log ( $ r1 ) ) ; $ row [ ] = $ r * sin ( $ r2 * self :: TWO_PI ) ; $ row [ ] = $ r * cos ( $ r2 * self :: TWO_PI ) ; } if ( count ( $ row ) > $ n ) { $ extras [ ] = array_pop ( $ row ) ; } $ a [ ] = $ row ; } return self :: quick ( $ a ) ; }
Return a standard normally distributed random matrix i.e values
between -1 and 1.

@param int $m
@param int $n
@throws \InvalidArgumentException
@return self
Return a standard normally distributed random matrix i . e values between - 1 and 1 .