# Random assignment

### Chong-ho (Alex) Yu, Ph.D., MCSE, CNE, CCNA

Problem:

I conduct an experiment for Web-based instruction. In my study there are one control group and two experimental groups. How could I randomly assign users to different groups?

Solution:

There are two ways to approach this problem.

Method 1

First, create a calculation field named "random_id" with this function: Int(Random * 3 + 1). The Random function generates a random number to each user. However, the random number is a very small real number such as 0.198762534. Therefore, the number should multiply itself by 3. Then the Int function converts the number to be an integer. The final output will fall within the range of 1 through 3. Next, create another calculation field called "assign" and use a case switch to redirect users to different webpages:

 Case( random_id = 1, "http://seamonkey.ed.asu.edu/control.html", random_id = 2, "http://seamonkey.ed.asu.edu/treatment1.html", random_id = 3, "http://seamonkey.ed.asu.edu/treatment2.html" )

Last, in the webpage you output the field "assign" as a hotlink. You could put it after the pretest or right after the login.

 Please go to the lesson now.

Please note that this random assignment will hardly produce groups with exactly same number of subjects. Ideally speaking, if the group sizes are all equal in a factorial design, the design is orthogonal and thus easier to interpret. To rectify this situation, you can administer the test and treatment to more subjects than what you need, then re-draw the same number of observations from each group. An alternative is to leave the group sizes uneven but apply Type III Sum of Squares in the analysis.

Method 2

Another way is more resource-consuming. But it still works. First, you create a database, and then inside the database you create a field named "URL" to carry the URL of different webpages. Next, you create a search page using a Random search button as shown in the following. When the button is pressed, a random page will be chosen.



Next, you can direct the user to the search_result.html. In this page the field value of URL is linked to the random-chosen page.

Special thanks to Tina Kimmel for her input in refining the Method 1.