Re: Generating normally distributed randoms in CL



* Tamas K Papp <6faot4FagfgbU1@xxxxxxxxxxxxxxxxxx> :
Wrote on 30 Jul 2008 09:00:20 GMT:

| On Tue, 29 Jul 2008 13:59:40 +0200, Pascal J. Bourguignon wrote:
|> "krzysztof.kielak@xxxxxxxxxxxxxx" <krzysztof.kielak@xxxxxxxxxxxxxx>
|> writes:
|>> Is there a simple way to generate normally distributed random data in
|>> CommonLisp?
[...]
|>> I'm looking for a package, that can handle this, and maybe also other
|>> statistical stuff
|>
|> (DEFUN NORMAL-RANDOM ()
|> (* (SQRT (* -2.0L0 (LOG (- 1.0L0 (RANDOM 1.0L0)))))
|> (COS (* 2.0L0 PI (RANDOM 1.0L0)))))
|>
|> do we really need yet another package for this simple function?
|
| In some cases you can find simple algorithms that you can easily
| implement, but having more advanced algorithms that are already written,
| debugged and tested (like the Ziggurat algorithm below) is always nice.
| For example, to solve differential equations, you can program an RK4
| solver really quickly. But you may not want to program a sophisticated
| adaptive-stepsize algorithm that handles stiffness when one is already
| available.

I suggest that there is another reason to use a well known
implementation.

For serious simulations you want to publish repeatable results,
_independent_ of the Common Lisp implementation you use---In that case
your simulation program cannot depend on a package which calls CL:RANDOM
[as different implementations will produce different sequences of
numbers]. It is preferable to use FFI to a "Standard" C implementation,
like the "RANLIB.C" package from NETLIB,

--
Madhu
.


Quantcast