• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

True Random Numbers

 
Ranch Hand
Posts: 515
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do I generate truely generate random numbers?
------------------
What's this H2SO4 doing in my fridge?? ( thud )
 
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Depends what you mean by truly random numbers... You can't do it on a computer for a start. Pretty much all 'random number' functions rely on pre-defined lists of numbers in some form or another. You normally have to give a seed (time in ms is often used), but if you know the seed you'd be able to work out what the number was.
Even if you had a (physical) lottery-style ball mixer, I wouldn't say that was truly random, as if you knew the exact position of every atom, and the laws of physics, you could work out what a number would be.
It isn't possible to know the exact position of every atom, so we could never do this, but it's still not truly random.
Hope that helps. G
 
Dale DeMott
Ranch Hand
Posts: 515
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is true. I'm looking for anything more than Pseudo-Random. The docs in the Java Visual Age mention a lot of Pseudo-Random functions that repeat and are hardily even close to random. The same numbers come up everytime I restart my program. I'm looking for something that doesn't come up with the same numbers come up everytime. This is a bit more clear?

------------------
What's this H2SO4 doing in my fridge?? ( thud )
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Normally the way that I do a pseudo random number is by setting the seed to the system time.
For example: (Like Grant Crofton suggested)
<CODE>
Random myRandom = new Random( System.currentTimeMillis() );
</CODE>
Since your system time is *somewhat* hard to guess correctly to the millisecond, this works as a good seed for randomizing.
Hope this helps.
 
You are HERE! The other map is obviously wrong. Better confirm with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic