Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #1450
| Date | 2011-12-15 13:11 -0800 |
|---|---|
| From | Patricia Shanahan <pats@acm.org> |
| 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> |
| Message-ID | <cJ-dnbLpvqsK_3fTnZ2dnUVZ_u-dnZ2d@earthlink.com> (permalink) |
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 | Next — Previous in thread | Find similar
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