• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

generation of random numbers without using Random

 
Bhayajis Bhayajis
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is there any way random numbers can be generated without using the Random
 
Joe Ess
Bartender
Pie
Posts: 9266
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bhayajis Bhayajis:
is there any way random numbers can be generated without using the Random

I don't suppose you are using Linux so you could just read from /dev/random?
You can do it mathematically, but pretty much any algorithm you'd come up with would either be (a) convergent (i.e. not very random) or (b) a re-implementation of java.math.Random. Basically you take a seed number (i.e. System.currentTimeMillis()) and use some function to generate a number. This is the first number in your series. You take that number and feed it back into your function to get the second random number in your series. Take the second number and feed it back in to get your third number and so on. The trick is to find a good function that evenly distributes the random numbers along the range you need without devolving into a predictable pattern and PROVING that behavior. I don't have my descrete mathematics textbook with me, so I can't come up with a good function offhand. Try googling for the subject. It sounds like a simple task but it is very complex.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bhayajis Bhayajis:
is there any way random numbers can be generated without using the Random

Why don't you want to use Random?
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just read in Wired about a web service you can call to get random numbers. They sample noise from a webcam with the lens cap on. They used to sample from an array of lava lamps. No kidding!
Hey, I just looked at The Site - you can dl the software and get a cheap webcam and generate your own at up to 200,000 bits per second. Neat.
[ October 07, 2003: Message edited by: Stan James ]
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
More inspired ideas for generating Random numbers.
or
Thomas Paul's Challenge: Optimum way to randomize 1,000,000 numbers
[ October 07, 2003: Message edited by: Cindy Glass ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic