Messages from list : cormas@cirad.fr

Choose a topic among the following archives :

Fw: normal distribution

New Message Reply Date view Thread view Subject view Author view

Subject: Fw: normal distribution
From: francois_bousquet (francois_bousquet@hotmail.com)
Date: sam déc 01 2001 - 05:04:07 CET

Hi Damien

Thank you for your contribution. For the normal distribution I recently
wrote the following method in response to an email from Jeljer. The zip
attached contains a Cormas model and the graphical test.
I realise that this is the same algorithm, I just multiplied by sigma and
added mu.
So we have consistent methods.
For Info : I programmed it from the Simulation reference book : Law, A. M.
and K. W.D. (1991). Simulation modeling and analysis, Mc Graw-Hill
international ed.

!Cormas class methodsFor: 'util_aleat'!

normal: mu sigma: s
 "polar method, Law et Kelton"

 | w u1 u2 v1 v2 y x1 x2 |
 w := 2.
 [w > 1] whileTrue:
   [u1 := Cormas random.
   u2 := Cormas random.
   v1 := 2 * u1 - 1.
   v2 := 2 * u2 - 1.
   w := v1 squared + v2 squared].
 y := (-2 * w ln / w) sqrt.
 x1 := v1 * y.
 x1 := mu + (s * x1).
 ^x1! !

New Message Reply Date view Thread view Subject view Author view
 

Back to home