Is it possible for lcg_value () to roll a perfect 1?

The name says it all. The documentation is unclear if lcg_value

choosing a number [0,1]

or [0,1)

.

+3


source to share


1 answer


  • The test shows that 0 and 1 are valid values. But...

  • PHP uses the Combined Linear Congruential Generator . Like the wiki, the value R

    cannot be equal 0

    (due to checking this) and cannot be equal 1

    (because X

    less m

    (because X is the result of a module m - 1

    ))



So the result lcg_value

belongs to (0,1) not to [0,1]

+2


source







All Articles