Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #34924

Re: Will Math.random return 0.0?

From Arne Vajhøj <arne@vajhoej.dk>
Newsgroups comp.lang.java.programmer
Subject Re: Will Math.random return 0.0?
Date 2016-07-16 16:47 -0400
Organization Aioe.org NNTP Server
Message-ID <nme6hs$1m5q$1@gioia.aioe.org> (permalink)
References <rand-20160716162126@ram.dialup.fu-berlin.de> <nme2i6$81t$1@dont-email.me> <nme4fm$83g$1@dont-email.me>

Show all headers | View raw


On 7/16/2016 4:12 PM, Eric Sosman wrote:
> On 7/16/2016 3:39 PM, Martin Gregorie wrote:
>> [...]
>> Meanwhile, your original code had been running for a while before I
>> developed and played with my extended version and has currently used
>> 100.5 minutes of MPU time, which is close to 1 hour 40 since its using
>> between 99 and 100% of the available CPU time from one of the two cores.
>> This is running on a laptop powered by a 1.6 GHz Core Duo with 3GB of RAM
>> and running Fedora 23 Linux.
>>
>> My billion sample run took 132 seconds to run, or 7.6 million samples
>> were generated and analysed per second.
>>
>> I'll leave your code running to see if it stops any time thus evening.
>
>     Back of the envelope: 2^53 possible numerators (maybe), one of
> which is all zero.

But the seed in the underlying RNG only has 48 bits.

>                7.6 million ~= 2^23 samples per second.  Time to
> cycle through all numerators ~= 2^(53-23) ~= 1E9 seconds, which is
> just about thirty-four years.  Maybe only half that if we leave out
> the analysis, so you should have a definite conclusion by 2033 or so.

Much sooner I think.

Arne

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Will Math.random return 0.0? Martin Gregorie <martin@address-in-sig.invalid> - 2016-07-16 19:39 +0000
  Re: Will Math.random return 0.0? Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-07-16 16:12 -0400
    Re: Will Math.random return 0.0? Martin Gregorie <martin@address-in-sig.invalid> - 2016-07-16 20:32 +0000
      Re: Will Math.random return 0.0? Martin Gregorie <martin@address-in-sig.invalid> - 2016-07-17 08:00 +0000
    Re: Will Math.random return 0.0? Arne Vajhøj <arne@vajhoej.dk> - 2016-07-16 16:47 -0400
    Re: Will Math.random return 0.0? Marcel Mueller <news.5.maazl@spamgourmet.org> - 2016-07-17 01:03 +0200

csiph-web