Spurred by discussions in the "DISCUSS: replace (rand)" thread, http://groups.google.com/group/clojure/browse_thread/thread/25dc26841ed00710/44050938894f9296?lnk=gst&q=rand#44050938894f9296
I've adapted, written, and tested some utilities for handling pseudorandom numbers. Here are the highlights: * random-seed returns a long (chosen more intelligently than java.math.random does) which can be used as a random seed for a pseudorandom number generator (PRNG) * transform-to-gaussian, due to Konrad Hinsen, transforms a seq of pseudorandom floating-point numbers uniformly distributed on [0,1), into a seq of Gaussian (mean 0, variance 1) pseudorandom floating- point numbers * test code includes a little gem for computing a running mean and variance (in a numerically stable way, no less!) of a finite seq whose length is not known I've tested the routines on a recent Clojure build and the following Java runtime: java version "1.6.0_10" Java(TM) SE Runtime Environment (build 1.6.0_10-b33) Java HotSpot(TM) 64-Bit Server VM (build 11.0-b15, mixed mode) on version 2.6.22 or so of the Linux kernel. Comments, bug reports, and suggestions for improving performance are welcome. (I realize now I forgot to include a utility for getting a double out of two pseudorandom ints -- I'll fetch one and add it next time.) mfh --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---