# Using R for statistics and probability need guidance.

#### lfdoray

##### New Member
I am very confused on my statistics and probability class and i need some help im using the R program i understand a little bit but there are some problems that give me headache.
Ex: Question: Suppose there are 10 students attending a class in the computer lab. Determine the probability that there will be enough computers for them. The matrix of 0’s and 1’s
Representing 100 simulations of 12 trials each. The number of 1’s in a row is the number of working computers, which we are calling x.

[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
[1,] 1 1 1 1 1 1 1 1 1 1 1 1 [2,] 1 1 1 1 1 1 1 1 1 1 1 1
[3,] 1 1 1 1 1 1 1 1 1 1 1 1 [4,] 1 1 0 1 0 1 1 1 1 1 1 1
[5,] 1 1 1 1 0 1 1 1 1 1 1 1[6,] 1 1 1 1 0 1 1 1 1 1 1 0
[7,] 1 0 1 1 1 1 1 1 1 1 1 1[8,] 0 1 1 1 1 1 1 1 1 1 1
[9,] 1 1 1 1 1 0 1 1 1 1 0 1[10,] 1 1 1 1 0 1 0 1 1 1 1 1
[11,] 1 1 1 1 1 1 0 1 1 1 1 0 [12,] 1 1 1 1 1 1 1 1 1 1 1 1
[13,] 1 1 1 1 1 1 1 1 1 1 1 1 [14,] 1 1 1 1 1 1 1 1 1 1 1 1
[15,] 1 1 1 1 0 1 1 1 1 1 1 1 [16,] 1 0 1 1 1 1 1 1 0 1 1 1
[17,] 1 1 1 0 1 1 1 1 1 1 1 1[18,] 1 1 1 1 1 1 1 1 1 1 1 1
[19,] 1 1 1 1 1 1 1 1 1 1 1 1 [20,] 1 1 1 1 1 1 1 1 1 1 1 1
[21,] 0 1 1 1 0 1 0 1 1 1 1 1 [22,] 1 0 1 0 1 1 1 1 1 1 1 1
[23,] 1 1 1 1 1 1 1 1 1 0 1 1
[24,] 1 0 1 1 1 1 1 1 1 1 1 1 [25,] 1 1 1 1 1 1 1 1 1 1 1 1
[26,] 0 1 1 1 1 1 1 1 1 1 1 1 [27,] 1 1 1 1 1 0 1 1 1 1 1 1
[28,] 1 1 1 1 1 1 1 1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 1 1
[100,] 1 1 1 1 1 1 1 1 1 1 1 1
> x = rowSums(computers);
> x;
[1] 12 12 12 10 11 10 11 11 10 10 10 12 12 12 11 10 11 12 12 12 9 10 11 11 12
[26] 11 11 12 12 12 11 10 12 11 11 12 12 11 10 12 12 11 12 12 8 12 12 12 11 11
[51] 10 11 12 11 12 12 11 11 12 12 10 11 10 12 12 11 10 11 9 10 12 12 12 10 11
[76] 11 11 10 11 10 12 11 11 10 8 12 11 10 11 11 10 11 12 11 10 11 12 12 12 12
> mean(x); sd(x); stem(x);
[1] 11.09
[1] 0.9330627

The decimal point is at the |

8 | 00
8 |
9 | 00
9 |
10 | 000000000000000000000
10 |
11 | 00000000000000000000000000000000000
11 |
12 | 0000000000000000000000000000000000000000

Question 1: compare the empirical mean and standard deviation with the
Theoretical values.
Question 2: How many computers were broken on the 5th simulated lab class?
Question 3: From the stem 'n' leaf plot what is the empirical probability that there will be enough working computers to accommodate the students?
question 4: Now use R to do 100 simulations for a class of 19 attending students in a lab with 20 Apple (Mac) computers
that each have a 5% chance of being broken. Copy your R commands/output to Word, and find the empirical
probability that there will be enough working computers?

#### Dason

Hi! :welcome: We are glad that you posted here! This looks like a homework question though. Our homework help policy can be found here. We mainly just want to see what you have tried so far and that you have put some effort into the problem. I would also suggest checking out this thread for some guidelines on smart posting behavior that can help you get answers that are better much more quickly.

#### lfdoray

##### New Member
Thanks for the reply I have actually tried and done the majority of it if someone could just explain me how to start and give me some tips i should be able to finish but at the moment i am stuck and lost.

#### Dason

Describe exactly what is giving you trouble. Sometimes you'll find that just the act of describing what is giving you trouble will help you understand your problem more and help you solve it yourself. But what you're asking right now is too much and too general. Ask a specific question and you'll be much more likely to get help.

#### lfdoray

##### New Member
thanks alot well how do you compare the empirical mean and standard deviation with the
Theoretical values.