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


Groups > comp.lang.java.help > #1450

Re: Generating a random number on a ball

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail
NNTP-Posting-Date Thu, 15 Dec 2011 15:11:50 -0600
Date Thu, 15 Dec 2011 13:11:44 -0800
From Patricia Shanahan <pats@acm.org>
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:8.0) Gecko/20111105 Thunderbird/8.0
MIME-Version 1.0
Newsgroups comp.lang.java.help
Subject Re: Generating a random number on a ball
References <18f0d020-b1ab-42fe-aaca-94d193a393f2@y6g2000yqe.googlegroups.com> <m1j7d7dj14j9fhn80jcfsnb7p03nujo584@4ax.com> <gnt6pl0t0agl$.1j1jobujp7x3w.dlg@40tude.net> <JJ-dnTn9OL9kYXrTnZ2dnUVZ_gOdnZ2d@earthlink.com> <Xns9FBC75229BE97vaj4088ianshef@138.125.254.103>
In-Reply-To <Xns9FBC75229BE97vaj4088ianshef@138.125.254.103>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 8bit
Message-ID <cJ-dnbLpvqsK_3fTnZ2dnUVZ_u-dnZ2d@earthlink.com> (permalink)
Lines 48
X-Usenet-Provider http://www.giganews.com
NNTP-Posting-Host 70.230.194.31
X-Trace sv3-CHEGjRFV8Z2O8/Cd2Z32SzcXRoYFgFKpPHXXrgo1DMPSsa9uHNToWUEOrRzMWH4XMj9lyZgVylF8D1B!5EB25uO6a6vpUosUtrWZpDaEK7vYqFqsIKOKT944Jjek+fxzJLaPF8cTW3eW1eAt1khrN+cbIcew!58W/I6C5whFWTakVDC3pMLSwcQeNK7JegqHnm30DGRzfZQ==
X-Abuse-and-DMCA-Info Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info Otherwise we will be unable to process your complaint properly
X-Postfilter 1.3.40
X-Original-Bytes 3205
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.help:1450

Show key headers only | View raw


On 12/15/2011 10:30 AM, Ian Shef wrote:
> Patricia Shanahan<pats@acm.org>  wrote in news:JJ-
> dnTn9OL9kYXrTnZ2dnUVZ_gOdnZ2d@earthlink.com:
>
>> Joerg Meier wrote:
>>> On Mon, 28 Nov 2011 10:02:01 -0800, Roedy Green wrote:
>>>
>>>> I don't see your random number code. See
>>>> http://mindprod.com/jgloss/pseudorandom.html
>>>> for how to generate the numbers Getting the number on the ball in 2D
>>>> is a matter of knowing where the ball is and doing a drawString.
>>>
>>> I looked at that and randomly saw:
>>>
>>> "Don¢t use two different generators with a null seed."
>>>
>>> Do you mean "0" seed, or no seed ? Because the Random constructor will not
>>> take null.
>>
>> No seed. The problem is that the default seed may not have changed, so
>> the two generators may be returning the same sequence of numbers.
>>
>> Patricia
>>
>
> This will also be a problem if two random number generators are seeded with
> identical seeds (e.g. 0).

Yes, the problem is having two generators with the same seed. Using the
default seed has a high risk of that condition. Using explicit identical
seeds makes it certain.

>
> If you are using two random number generators, you should supply the seeds
> for both of them, and the seeds should be different.  If you supply the seed
> to only one of them, you stand a possibility (although small) that it is
> identical to the default seed used for the other.

One technique that I've used is to have a SecureRandom generate the
seeds.

In addition to avoiding identical seeds, using explicit seeds allows
logging of the seeds. I also like to have a way to force the seeds to
supplied values. That way, I can reproduce the random number sequences
for a prior run, a feature that is useful both for testing and for debug.

Patricia

Back to comp.lang.java.help | Previous | NextPrevious in thread | Find similar


Thread

Generating a random number on a ball Michael Adedeji <yankosmgt@gmail.com> - 2011-11-28 05:53 -0800
  Re: Generating a random number on a ball Patricia Shanahan <pats@acm.org> - 2011-11-28 07:04 -0800
  Re: Generating a random number on a ball Roedy Green <see_website@mindprod.com.invalid> - 2011-11-28 10:02 -0800
    Re: Generating a random number on a ball Joerg Meier <joergmmeier@arcor.de> - 2011-12-14 01:20 +0100
      Re: Generating a random number on a ball Patricia Shanahan <pats@acm.org> - 2011-12-13 17:33 -0800
        Re: Generating a random number on a ball Ian Shef <invalid@avoiding.spam> - 2011-12-15 18:30 +0000
          Re: Generating a random number on a ball Patricia Shanahan <pats@acm.org> - 2011-12-15 13:11 -0800

csiph-web