Pregunta

I have three variables ran1 - ran3. They are required to receive values between [ran1, ran2] 1-999 (integer) and [ran3] 0-1 (float)

I have been happily doing this:

* COMPUTE ran1 = TRUNC(UNIFORM(999)) + 1 .  * produces values between 1 and 999
* COMPUTE ran2 = TRUNC(UNIFORM(999)) + 1 .  * produces values between 1 and 999
* COMPUTE ran3 = UNIFORM(1) .               * produces values between 0.01 and 0.99

but have been advised that a normal distribution would be more useful for what follows.

So, I did this:

COMPUTE ran1 = TRUNC(NORMAL(999)) + 1 .     * produces values between -4900 and +4744
COMPUTE ran2 = TRUNC(NORMAL(999)) + 1 .     * produces values between -4748 and +4902 
COMPUTE ran3 = NORMAL(2) .                  * produces values between -11.10 and +10.72

Why are the values now clustered around zero? What do I do to get them within the required ranges?

Thanks.

¿Fue útil?

Solución

You are using the old form of the normal RNG. In that function, the parameter is sigma, not the mean.

Use RV.NORMAL(mean, std deviation).

The RV.xxx notation can be used for all the random number generators, including RV.UNIFORM(min, max).

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top