php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78233 stats_rand_gen_* functions do not generate random values.
Submitted: 2019-06-29 15:01 UTC Modified: 2019-09-07 14:11 UTC
From: siad dot ardroumli at gmail dot com Assigned:
Status: Not a bug Package: stats (PECL)
PHP Version: 7.3.6 OS: Windows 10 Home
Private report: No CVE-ID: None
 [2019-06-29 15:01 UTC] siad dot ardroumli at gmail dot com
Description:
------------
Using the function stats_rand_gen_normal() produces always the same number.

For example stats_rand_gen_normal(0,1) will always produce 0.87032747268677

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

Test script:
---------------
<?php

echo stats_rand_gen_normal(0,1);
echo PHP_EOL;
echo stats_rand_gen_normal(0,1);
echo PHP_EOL;
echo stats_rand_gen_normal(0,1);


Expected result:
----------------
A random normal number.

Actual result:
--------------
Always the same normal number for the same arguments used.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-06-29 19:08 UTC] siad dot ardroumli at gmail dot com
-Summary: stats_rand_gen_normal produces no random number +Summary: stats_rand_gen_* functions do not generate random values.
 [2019-06-29 19:08 UTC] siad dot ardroumli at gmail dot com
It seems that all stats_rand_gen_* functions do not generate random values.
 [2019-09-07 14:08 UTC] uchiyama@php.net
Not a bug. You need to call stats_rand_setall(int $iseed1, int $iseed2) with arbitrary int pair.
If you don't call it explicitly, $iseed1=1234567890 and $iseed2=123456789 are used in default.

See also
https://www.php.net/manual/en/function.stats-rand-setall.php
 [2019-09-07 14:11 UTC] uchiyama@php.net
-Status: Open +Status: Not a bug
 [2019-09-07 14:11 UTC] uchiyama@php.net
Not a bug, as I commented.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Nov 10 15:01:28 2024 UTC