Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't set normal distribution precision to zero #27

Open
kAlvaro opened this issue Jan 12, 2018 · 0 comments
Open

Can't set normal distribution precision to zero #27

kAlvaro opened this issue Jan 12, 2018 · 0 comments

Comments

@kAlvaro
Copy link

kAlvaro commented Jan 12, 2018

<?php
use \Malenki\Math\Stats\NormalDistribution;

require_once __DIR__ . '/vendor/autoload.php';

$normal = new NormalDistribution(1000, 50);
$normal->precision(0);
var_dump($normal->samples(5));

... prints:

array(5) {
  [0]=>
  float(1111.8813325362)
  [1]=>
  float(1040.4406411515)
  [2]=>
  float(973.58864510718)
  [3]=>
  float(969.1747970471)
  [4]=>
  float(1031.454325518)
}

The culprit is this construct, used in several places:

if ($this->int_precision) {
    return round($float_variance, $this->int_precision);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant