Messages from list : cormas@cirad.fr

Choose a topic among the following archives :

Correlated random numbers ...

New Message Reply Date view Thread view Subject view Author view

Subject: Correlated random numbers ...
From: Jourdain, Damien (D.JOURDAIN@CGIAR.ORG)
Date: lun nov 26 2001 - 18:08:00 CET

Thank you Pierre and Louise for the prompt answer on Random numbers. It is
working now.

I have another question related to random numbers and somehow tougher!

How can I do if I want to generate two (or more) series of random numbers
that are correlated.

For example, I want to generate a first serie of number following the normal
distribution N(1500, 100), and a second serie of number following also a
normal distribution N(2000, 300), and I want a coefficient of correlation
between the two series of let say 0.8?

Any simple solution?

Damien

-----Original Message-----
From: Pierre Bommel [mailto:bommel@cirad.fr]
Sent: Monday, November 26, 2001 9:55 AM
To: Jourdain, Damien
Cc: cormas@cnusc.fr
Subject: Re: Random numbers ...

Hello Damien,

Jourdain, Damien wrote:

> Dear all,
>
> I try to generate a serie of random numbers uniformely distributed between
> let say 0.7 and 0.1. I thought the routine to use would look something
like
>
> | x y |
> x := OrderedCollection new.
> 1 to: 100 do: [ :p |
> y := Cormas randomFrom: 0.7 to: 1.
> x add: y.
> ].
>
> This, in fact generate a serie of numbers that are either 0.7 or 1 but
> nothing in between.
> What did I do wrong?
>
The class method "randomFrom:to:" return an integer (if the start value
is an integer), for example: Cormas randomFrom: 7 to: 10 can only return
4 values = 7, 8, 9 or 10.
In your case, if you want a collection of floats, between 0.7 and 1 with
a precision of 3, you can do that by this way :

| x y |
x := OrderedCollection new.
1 to: 100 do: [ :p |
                y := (Cormas randomFrom: 700 to: 1000)/1000 asFloat.
                x add: y].

Best regards,

        Pierre

-- 
**************************************
* Pierre Bommel                      *
* CIRAD TA 60/15                     *
* 73, rue Jean-François Breton       *
* 34398 Montpellier cedex 5 France   *
* Phone: +33 (0)4 67 59 38 53        *
* Fax: +33 (0)4 67 59 38 27          *
* http://cormas.cirad.fr             *
**************************************

New Message Reply Date view Thread view Subject view Author view
 

Back to home