jQuery in Action, 2nd edition*
The moose likes Java in General and the fly likes generation of random numbers without using Random Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "generation of random numbers without using Random" Watch "generation of random numbers without using Random" New topic
Author

generation of random numbers without using Random

Bhayajis Bhayajis
Greenhorn

Joined: Sep 29, 2003
Posts: 9
is there any way random numbers can be generated without using the Random
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8843
    
    7

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.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
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?


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
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 ]

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
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 ]

"JavaRanch, where the deer and the Certified play" - David O'Meara
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: generation of random numbers without using Random
 
Similar Threads
lockCookie
random number generation
random images
random number generation
Arrays