random numbers

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

random numbers

Arthur Kramer

I would like to generate two random distributions of 25 cases, say with means of 22 and 27 and standard deviations of 5 and 6.  Can this be done with SPSS? If so, how?

 

Thanks for any help you can provide.

 

Arthur Kramer

 

Reply | Threaded
Open this post in threaded view
|

Re: random numbers

Art Kendall
Open a new instance of SPSS.  Copy and paste the example syntax below into a syntax window. Run it. You can change the N, means, and SDs.


* prepare two distributions as if for t-test.
set seed 20101802.
input program.
loop #i = 1 to 25.
compute group =1.
compute x = rv.normal(22,5).
end case.
end loop.
loop #i = 1 to 25.
compute group =2.
compute x = rv.normal(27,6).
end case.
end loop.
end file.
end input program.
T-TEST GROUPS=group(1 2) /variables = x.


Art Kendall
Social Research Consultants

On 2/18/2010 1:59 PM, Arthur Kramer wrote:

I would like to generate two random distributions of 25 cases, say with means of 22 and 27 and standard deviations of 5 and 6.  Can this be done with SPSS? If so, how?

 

Thanks for any help you can provide.

 

Arthur Kramer

 

===================== 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
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: random numbers

Arthur Kramer

Perfect. Thanks.

 

Arthur Kramer

 

 


From: Art Kendall [mailto:[hidden email]]
Sent: Thursday, February 18, 2010 2:26 PM
To: Arthur Kramer
Cc: [hidden email]
Subject: Re: [SPSSX-L] random numbers

 

Open a new instance of SPSS.  Copy and paste the example syntax below into a syntax window. Run it. You can change the N, means, and SDs.


* prepare two distributions as if for t-test.
set seed 20101802.
input program.
loop #i = 1 to 25.
compute group =1.
compute x = rv.normal(22,5).
end case.
end loop.
loop #i = 1 to 25.
compute group =2.
compute x = rv.normal(27,6).
end case.
end loop.
end file.
end input program.
T-TEST GROUPS=group(1 2) /variables = x.


Art Kendall
Social Research Consultants

On 2/18/2010 1:59 PM, Arthur Kramer wrote:

I would like to generate two random distributions of 25 cases, say with means of 22 and 27 and standard deviations of 5 and 6.  Can this be done with SPSS? If so, how?

 

Thanks for any help you can provide.

 

Arthur Kramer

 

Reply | Threaded
Open this post in threaded view
|

Re: random numbers

Bruce Weaver
Administrator
In reply to this post by Arthur Kramer
Arthur Kramer wrote
I would like to generate two random distributions of 25 cases, say with
means of 22 and 27 and standard deviations of 5 and 6.  Can this be done
with SPSS? If so, how?



Thanks for any help you can provide.



Arthur Kramer
Hi Art.  You didn't say what kind of distribution you want to sample from, so I will assume it is normal.

* If you want 2 variables side by side .

new file.
dataset close all.
input program.
loop #i = 1 to 25.
 compute case = $casenum.
 compute x1 = rv.normal(22,5). /* Mean=22, SD=5 .
 compute x2 = rv.normal(27,6). /* Mean=27, SD=6 .
end case.
end loop.
end file.
end input program.
exe.

means x1 x2.

* If you want one X-variable with a Group variable.

new file.
dataset close all.
input program.
loop #i = 1 to 50.
 compute case = $casenum.
 do if case LE 25.
  compute group = 1.
  compute x = rv.normal(22,5).
 else.
  compute group = 2.
  compute x = rv.normal(27,6).
 end if.
end case.
end loop.
end file.
end input program.
exe.

means x by group.

There are RV functions for a bunch of other distributions too, if you don't want the normal.  Search for "Random variable functions" under Help - Topics - Index.

HTH.

Cheers,
Bruce
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: random numbers

Arthur Kramer
Thanks, that works great also. An hour ago I didn't have anything, now I
have two.  Life is good!

Arthur Kramer


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Bruce Weaver
Sent: Thursday, February 18, 2010 2:30 PM
To: [hidden email]
Subject: Re: random numbers

Arthur Kramer wrote:

>
> I would like to generate two random distributions of 25 cases, say with
> means of 22 and 27 and standard deviations of 5 and 6.  Can this be done
> with SPSS? If so, how?
>
>
>
> Thanks for any help you can provide.
>
>
>
> Arthur Kramer
>
>
>

Hi Art.  You didn't say what kind of distribution you want to sample from,
so I will assume it is normal.

* If you want 2 variables side by side .

new file.
dataset close all.
input program.
loop #i = 1 to 25.
 compute case = $casenum.
 compute x1 = rv.normal(22,5). /* Mean=22, SD=5 .
 compute x2 = rv.normal(27,6). /* Mean=27, SD=6 .
end case.
end loop.
end file.
end input program.
exe.

means x1 x2.

* If you want one X-variable with a Group variable.

new file.
dataset close all.
input program.
loop #i = 1 to 50.
 compute case = $casenum.
 do if case LE 25.
  compute group = 1.
  compute x = rv.normal(22,5).
 else.
  compute group = 2.
  compute x = rv.normal(27,6).
 end if.
end case.
end loop.
end file.
end input program.
exe.

means x by group.

There are RV functions for a bunch of other distributions too, if you don't
want the normal.  Search for "Random variable functions" under Help - Topics
- Index.

HTH.

Cheers,
Bruce


-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/
"When all else fails, RTFM."

NOTE:  My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.
--
View this message in context:
http://old.nabble.com/random-numbers-tp27643894p27644333.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
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