Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #34915
| From | Thomas Richter <thor@math.tu-berlin.de> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Will Math.random return 0.0? |
| Date | 2016-07-16 18:53 +0200 |
| Organization | University of Stuttgart, FRG |
| Message-ID | <nmdoqg$o6a$1@news2.informatik.uni-stuttgart.de> (permalink) |
| References | <rand-20160716162126@ram.dialup.fu-berlin.de> <nmdoj4$s2i$1@dont-email.me> |
Am 16.07.2016 um 18:49 schrieb Eric Sosman:
>
>> Can we be sure that it will ever terminate?
>
> Yes.
>
No. A couple of well-understood "random" generators are simply of the form
x_n = (x_{n-1} * a) mod b
with a and b some relatively prime numbers. These are not particularly
good generators, but often simple to implement and fast - even more so
if b is (one minus) a power of two.
In such a case, zero is a trivial period of the generator, and for that
reason, the generator is never initialized by zero. It then can be seen
that it never reaches zero either (given the ring Z_b has no zero dividers).
Random() on such a core random generator would return the number x_n
divided by b, and hence the output would never be zero.
Again, whehter this generator is an acceptable generator for Java
implementations I cannot say, but it is at least a well-studied (not-so,
but sufficiently) random generator that has been used in the past.
Greetings,
Thomas
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Will Math.random return 0.0? Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-07-16 12:49 -0400
Re: Will Math.random return 0.0? Thomas Richter <thor@math.tu-berlin.de> - 2016-07-16 18:53 +0200
Re: Will Math.random return 0.0? Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-07-16 13:11 -0400
Re: Will Math.random return 0.0? Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-07-17 08:06 -0400
Re: Will Math.random return 0.0? Arne Vajhøj <arne@vajhoej.dk> - 2016-07-16 14:17 -0400
csiph-web