PROGRAMMING IN R: I need to know how to code it. (Not sure what it is asking.) I
ID: 3206049 • Letter: P
Question
PROGRAMMING IN R: I need to know how to code it. (Not sure what it is asking.)
I. The goal of this problem is to simulate a binomial random variable. Consider a class with 40 students, and the probability that a student does not turn in a homework is 0.05 (a “success”). Assume all students are independent of all other students, and the probability does not change.
(a) Use sample to simulate drawing 40 students who either do, or do not, turn in their homework, and then find the total (out of 40) who did not turn in their homework. You should return one number, X = total # of students out of 40 who did not turn in their homework.
Explanation / Answer
Solution
Steps involved
1. Pick 2-digit random numbers in a sequence.
2. If the random number is one of {00, 01, 02, 03, 04}, take that the student does not turn in the homework. All other random numbers upto and including 99 represent students who have turned in the homework.
3. Continue till 40 valid results are obtained ignoring repeat random numbers.
4. Once Step 3 is completed, count the number of students with random numbers from {00, 01, 02, 03, 04}. And that gives the required count.
Working
Random numbers are picked from the excerpt of the following:
RAND Corporation - RAND's A Million Random Digits with 100,000 Normal Deviates
Set A: students who do not turn in homework
Set B: students who do not turn in homework
R: Repeat
Random
Number
15
83
84
71
74
76
86
61
43
30
89
79
33
43
78
Set
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
Random
Number
08
73
05
65
22
78
15
52
24
66
81
97
85
32
31
Set
B
B
B
B
B
R
B
B
B
B
B
B
B
B
B
Random
Number
63
81
66
20
71
16
98
99
31
47
50
02
80
82
75
Set
B
R
R
B
R
B
B
B
R
B
B
A
B
B
B
Thus, out of 45 random numbers picked, 5 got rejected due to repetition,
39 belong to Set B and only 1 belonged to Set A.
So, X = 1. ANSWER
Random
Number
15
83
84
71
74
76
86
61
43
30
89
79
33
43
78
Set
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
Random
Number
08
73
05
65
22
78
15
52
24
66
81
97
85
32
31
Set
B
B
B
B
B
R
B
B
B
B
B
B
B
B
B
Random
Number
63
81
66
20
71
16
98
99
31
47
50
02
80
82
75
Set
B
R
R
B
R
B
B
B
R
B
B
A
B
B
B
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.