Replicating random numbers

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Replicating random numbers

Mario Giesel-2
Dear SPSS friends,

  I want to replicate a random variable created by function RV.NORMAL().
I tried these syntaxes but don't get the expected results as test1 has other values than test2.

* Trial 1.
SET SEED = 11.
COMPUTE test1 = RV.NORMAL(100, 10).
SET SEED = 11.
COMPUTE test2 = RV.NORMAL(100, 10).

* Trial 2.
SET RNG=MT MTINDEX=1.
COMPUTE test1 = RV.NORMAL(100, 10).
SET RNG=MT MTINDEX=1.
COMPUTE test2 = RV.NORMAL(100, 10).

What am I doing wrong?
Thanks for any hint!
 
Mario Giesel
Munich, Germany
===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Replicating random numbers

Kirill Orlov
You forgot EXECUTE command between the two tests. Without it, only first number seed is in effect and both variables are computed at one run, case by case.

19.12.2017 17:03, Mario Giesel пишет:
Dear SPSS friends,

  I want to replicate a random variable created by function RV.NORMAL().
I tried these syntaxes but don't get the expected results as test1 has other values than test2.

* Trial 1.
SET SEED = 11.
COMPUTE test1 = RV.NORMAL(100, 10).
SET SEED = 11.
COMPUTE test2 = RV.NORMAL(100, 10).

* Trial 2.
SET RNG=MT MTINDEX=1.
COMPUTE test1 = RV.NORMAL(100, 10).
SET RNG=MT MTINDEX=1.
COMPUTE test2 = RV.NORMAL(100, 10).

What am I doing wrong?
Thanks for any hint!
 
Mario Giesel
Munich, Germany
===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD


===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Replicating random numbers

Mario Giesel-2
Thanks, Kyrill.
However, EXECUTE makes no difference on my computer.
 
Mario Giesel
Munich, Germany


Kirill Orlov <[hidden email]> schrieb am 15:24 Dienstag, 19.Dezember 2017:


You forgot EXECUTE command between the two tests. Without it, only first number seed is in effect and both variables are computed at one run, case by case.

19.12.2017 17:03, Mario Giesel пишет:
Dear SPSS friends,

  I want to replicate a random variable created by function RV.NORMAL().
I tried these syntaxes but don't get the expected results as test1 has other values than test2.

* Trial 1.
SET SEED = 11.
COMPUTE test1 = RV.NORMAL(100, 10).
SET SEED = 11.
COMPUTE test2 = RV.NORMAL(100, 10).

* Trial 2.
SET RNG=MT MTINDEX=1.
COMPUTE test1 = RV.NORMAL(100, 10).
SET RNG=MT MTINDEX=1.
COMPUTE test2 = RV.NORMAL(100, 10).

What am I doing wrong?
Thanks for any hint!
 
Mario Giesel
Munich, Germany
===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD


===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD


===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Replicating random numbers

Kirill Orlov
* Trial 1.
SET RNG=MC.
SET SEED=11.
COMPUTE test1 = RV.NORMAL(100, 10).
exec.
SET SEED=11.
COMPUTE test2 = RV.NORMAL(100, 10).
exec.


* Trial 2.
SET RNG=MT.
SET MTINDEX=1.
COMPUTE test1 = RV.NORMAL(100, 10).
exec.
SET MTINDEX=1.
COMPUTE test2 = RV.NORMAL(100, 10).
exec.


===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Replicating random numbers

Jon Peck
From the CSR.

This command [SET] takes effect immediately. It does not read the active dataset or execute pending
transformations.

So the second SET  command is executed BEFORE the transformations are calculated and, hence, has no effect here.  (The appropriate SET also depends on the selected random number generator.)

This is one of the rare cases when an EXECUTE command is necessary.

On Tue, Dec 19, 2017 at 7:34 AM, Kirill Orlov <[hidden email]> wrote:
* Trial 1.
SET RNG=MC.
SET SEED=11.
COMPUTE test1 = RV.NORMAL(100, 10).
exec.
SET SEED=11.
COMPUTE test2 = RV.NORMAL(100, 10).
exec.


* Trial 2.
SET RNG=MT.
SET MTINDEX=1.
COMPUTE test1 = RV.NORMAL(100, 10).
exec.
SET MTINDEX=1.
COMPUTE test2 = RV.NORMAL(100, 10).
exec.


===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD



--
Jon K Peck
[hidden email]

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Replicating random numbers

Mario Giesel-2
In reply to this post by Kirill Orlov
Thanks, Kirill,

  your example works fine.
I understand now that it is not sufficient to set the seed but it is as well important to set RNG=MC.
Because RNG=MT and setting the seed does not work here.

Thanks also to Jon for your explanation.
Merry Christmas to all!
 
Mario Giesel
Munich, Germany


Kirill Orlov <[hidden email]> schrieb am 15:35 Dienstag, 19.Dezember 2017:


* Trial 1.
SET RNG=MC.
SET SEED=11.
COMPUTE test1 = RV.NORMAL(100, 10).
exec.
SET SEED=11.
COMPUTE test2 = RV.NORMAL(100, 10).
exec.


* Trial 2.
SET RNG=MT.
SET MTINDEX=1.
COMPUTE test1 = RV.NORMAL(100, 10).
exec.
SET MTINDEX=1.
COMPUTE test2 = RV.NORMAL(100, 10).
exec.



===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD


===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD