02/15/16, 3:06 PM 1/4 Homework 1: (50 points in total) Excel macro worksheet: Q1 How many participants participated in this experiment (total)? Divide them into two conditions (Cond 1 and Cond 2) and the two versions (version 1 and version 2) and fill out the table in the excel sheet. Use an Excel macro to facilitate the task. (5 points) Q2. Carry out the following with your own Excel macro. (5 points) For each participant (Sub ID column), copy their response time cells (column F) and paste them horizontally with respect to each subject ID in column A. Repeat this for all participants. Your answer should look like below: 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 Cond 1 Cond 1 Cond 1 Cond 1 Cond 1 Cond 1 Cond 1 Cond 1 Cond 1 Cond 1 Cond 1 Cond 1 Cond 1 Cond 1 Cond 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 high high high high high medium medium medium medium medium low low low low low 4273 6749 7013 2771 3973 3787 2338 4204 2102 2512 1924 1918 3050 2909 2405 4273 6749 7013 2771 3973 3787 2338 4204 2102 Hint: Use the “paste special” function” from “Edit” menu, and select “transpose” While doing that, record “macro” (select Tools/Macros/Record New Macro from the menu bar). Excel Graphics Q3. Draw the following two functions using an excel graphic function. (10 points) y 1 (1 exp( 4 0.1x)) y 1 (1 exp( 5.8 0.1x)) -- (1) -- (2) The range of x should be (0, 100). 02/15/16, 3:06 PM 2/4 Hints: 1. To make a graph, use Excel Graphics (see below) and a x-y scatter plot in it. 2. For the exponential function, use “=exp()” 3. Divide x into equally spaced bins VBA Programming Program 1. Create a procedure that takes K (integer) as a variable, and print N samples of random integers ranging from 1 to K in Program 1 worksheet. Test your program with N = 100 and K=20. Use RandomInteger() to produce a random integer ranging from 1 to K (see below). Print the result on excel worksheet “Program 1.” Your program should look like this: (10 points) Private sub RandomK () Dim K as integer Dim N as integer K=xxx 02/15/16, 3:06 PM 3/4 N=xxx ‘ write your program end sub Hint: use the following function to generate a random integer. Private Function RandomInteger(thisRange As Integer) As Integer Dim MyValue Randomize RandomInteger = Int((thisRange * Rnd) + 1) 'create a random number between 1 and thisRange End Function Program 2. Write a procedure that randomly assigns 4 conditions, a1, a2, a3, and a4, to 100 subjects. Print the result on the excel sheet “Program 2” with subject ID numbers in column A and their conditions in column B. (10 points) Hint: Use RandomInteger() and a if then control function Program 3. Write a procedure that randomly assign 4 conditions, a1, a2, a3, and a4, to 100 subjects with a restriction that each condition receives the same number of subjects (a1=a2=a3=a4=25). (10 points) Private Sub PrintRandomSample1 () 02/15/16, 3:06 PM 4/4 ‘create random integers ranging from 1 to K, L times, and print the random samples in the row 1 to L. End sub