Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

random number

 
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How computer generates random number???
 
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
They use one or another kind of algorithm. Check API documentation of Random class.

I have not gone thru, but I beleive if you can just open java\util\Random.java file, you will be able to see logic.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wikipedia: Random Number Generation has a brief introduction, and lots of links for further research. If you're interested in Java code, have a look at the java.util.Random class - its source comes with the JDK and is commented.
[ September 26, 2006: Message edited by: Ulf Dittmer ]
 
lowercase baba
Posts: 13091
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One could argue that computers do NOT generate random numbers, but PSEUDO random numbers.

there is a defined algorithm for generating the number. If i knew what that algorithm is, and had the proper information, i could tell you exactly what the next numbe would be. therefore, it is not random.

however, most people do not have access to that information, so it works well enough - it simulates a Random Number Generator.
 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by fred rosenberger:
One could argue that computers do NOT generate random numbers, but PSEUDO random numbers.

there is a defined algorithm for generating the number. If i knew what that algorithm is, and had the proper information, i could tell you exactly what the next numbe would be. therefore, it is not random.

however, most people do not have access to that information, so it works well enough - it simulates a Random Number Generator.



We both think more or less same.
Thanks All.
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I saw a neat story about some guys who bought a slot machine identical to those used in several casinos, reverse engineered the random number generator, found it was tied to a clock and they could predict times that would cause a payout. The computer guy got on the phone with a partner in the casino who signaled the player when to pull the lever. Pretty slick.

I keep reading about RNGs that use heat and electronic noise inside the computer instead of algorithms to generate a new number from the one before. I'm sure we'll have quantum RNGs soon enough. Open a box, check the state of the cat for the seed or something like that.
 
reply
    Bookmark Topic Watch Topic
  • New Topic