Random Number Generator Program

Graziano and Raulin



For your convenience, we have written a random number generator program, which you can download from this site. The program was written in Turbo Pascal by Windy Weaver and Mike Raulin and compiled to an EXE file. You can download the file by clicking on the filename below. This program is available for use by anyone who is using, or has used, the Graziano and Raulin Research Methods textbook.

Click on the filename to download the program: randnum.exe


Operational Instructions

The random number generating program, RANDNUM.EXE, is simple to run and is menu driven. To run the program in Windows or Windows 95, simply double-click on the filename RANDNUM.EXE from the file manager or Windows Explorer. The program will print the output to the screen, but will also write the output to a text file (RAND-OUT.TXT). The output file can be printed for later reference using Notepad or any word processing program. Please note that each time the program is run it will overwrite the out put file, so if you want to keep a copy, either print the output file or rename it before running the program again.

We recommend that you print out this page as a reference for the program.

Options

The random number program has four options that are accessed through two levels of menus. Each of the options are listed below, along with the menu choices to activate the choice.

Simple List of Random Numbers

This option will give you a list of random numbers with no constraints on the numbers. The program will ask you for the highest number desired, the lowest number desired, and how many random numbers you want. This option will effectively produce a ra ndom number table such as the one that appears in Appendix B of the text. To access this option, select choice 1 from the first menu and choice 1 from the second menu.

List of Random Numbers with No Repeated Numbers

This option will give you a list of random numbers with no duplicate numbers. The program will ask you for the highest number desired, the lowest number desired, and how many random numbers you want. Because this option does not repeat any of the ran dom integers, the range (highest minus lowest score) must be at least as large as the number of random integers requested. This option is especially useful for random sampling from a population, where each population member is given a unique sequential n umber. For example, if you want to sample 50 subjects from a population of 4000, number each subject in the population from 1 to 4000 and then request that the program give you 50 random numbers between 1 and 4000. To access this option, select choice 1 from the first menu and choice 2 from the second menu.

Free Random Assignment to Groups

This option will produce a list of random numbers for random assignment to groups. There are no restrictions on the random numbers, so it is likely that the groups will not have the same sample size. The program will ask you for the number of groups and the number of subjects that you want to assign. To access this option, select choice 2 from the first menu and choice 1 from the second menu.

Random Assignment within Blocks to Groups

This option will produce a list of random numbers for random assignment to groups, where the groups are randomized within blocks. For example, if you have four groups and 60 subjects to assign, the first four random numbers will be 1 through 4 in a ra ndom order, followed by another random order of 1 through 4, and so on. Randomizing within blocks assures that the number of subjects will be equal or close to equal in the groups. It is also useful for matched random assignment (see pages 217-219) or f or generating random ordering of conditions for within-subjects designs (see pages 259-263). When using the program for random ordering of conditions, you should tell the program that the number of subjects is equal to the actual number of subjects times the number of conditions. For example, if you have 30 subjects and 4 conditions, tell the program that you have 120 subjects (30 X 4) and 4 conditions. The program will then produce 30 blocks of 4 conditions, each block representing a random order of c onditions. [Note that the program will print out full blocks of assignments. For example, if you request the assignment of 22 subjects to 4 condition, the program will print out 24 assignment (6 blocks of 4).] To access this option, select choice 2 fro m the first menu and choice 2 from the second menu.

Printing the Output File

The easiest way to get a copy of the list of random numbers is to open the file RAND-OUT.TXT using either Notepad or your word processing program, and then print the file from the program. The file will be written to the subdirectory from which the RA NDNUM.EXE program was run. The output is formatted to print on standard size paper. If you want to save the output file, we recommend that you save it under another name so that you do not accidently overwrite it when you run the RANDNUM.EXE program aga in.




Return to Student Resource Page

Return to Graziano and Raulin Home Page


Michael L. Raulin, Ph.D.
(716) 645-3697
Psychology Department
SUNY at Buffalo
Buffalo, NY 14260-4110
raulin@acsu.buffalo.edu

Copyright © 1997, Mike Raulin
Revised: February 25, 1997
URL: http://www.buffalo.edu/~raulin/random.html
Home Page: http://www.buffalo.edu/~raulin/resmeth.html