2

With PHP 7.3, I'm trying to use the PECL stats extension: https://pecl.php.net/package/stats

Especially, I'm interested in generating random values following a normal distribution, with the function stats_rand_gen_normal

In my script, the function always returns the same result. I tried in CLI, to be sure :

php -r "echo(stats_rand_gen_normal(0,1));"

Every execution prints the same number.

So it's a random value which is always the same... What am I missing here?

Eria
  • 2,653
  • 6
  • 29
  • 56

2 Answers2

2

This seems to me like a bug too and I have make a bug report. There is a solution on stackoverflow using a custom function.

Siad Ardroumli
  • 596
  • 2
  • 9
1

You should use stats_rand_setall() to seed values to the random generator.

Vitaly Chirkov
  • 1,692
  • 3
  • 17
  • 33