[opensource] Random seed

James Dinan dinan at cse.ohio-state.edu
Tue Mar 20 15:37:57 EDT 2007


BRIAN SWANEY wrote:
> Regarding the class, I quite agree in how sloppy it is to have the
> whole code in 1 file, but I don't yet know how to put it into another
> class. I tried once, and it just started calling it undefined. If
> someone knows how (which I'm sure they do), some advice on doing that
> would be greatly appreciated...

Sun has some decent online tutorials that you may find helpful.  Here is
one on using Classes:

http://java.sun.com/docs/books/tutorial/java/concepts/index.html

> I thought it was a bad random seed all this time. As for the
> pseudorandom thing, I think I'm just going to update a seed input
> each time by writing it to a file and re-reading it the next time the
> file is opened.

One trick people use for generating randomness is seeding the random
number generator using the clock.  In fact, if you do not seed the Java
random number generator this is exactly what the default constructor does:

http://www.java-tips.org/other-api-tips/weka/i-get-the-same-sequence-of-random-numbers.-can-i-specify-random-seeds-to-random-number-gene.html

 ~Jim.


More information about the Opensource mailing list