A.
Consider a population consisting of the following values, which represents the number of ice cream purchases during the academic year for each of the five housemates.
8, 14, 16, 10, 11
a. Compute the mean of this population.
> x <- c(8, 14, 16, 10, 11)
> avg_pop <- mean(x)
> avg_pop
[1] 11.8
b. Select a random sample of size 2 out of the five members. See the example I used in my Power-point presentation slide # 13.
> sample(x, size=2)
[1] 8 14
c. Compute the mean and standard deviation of your sample.
> x_sample <- sample(x, size=2)
> avg_sample <- mean(x_sample)
> sd_sample <- sd(x_sample)
> avg_sample
[1] 11
> sd_sample
[1] 4.242641
d. Compare the Mean and Standard deviation of your sample to the entire population of this set (8,14, 16, 10, 11).
> avg_sample
[1] 11
> sd_sample
[1] 4.242641
> avg_pop
[1] 11.8
> sd_pop
[1] 3.193744
The average sample is 0.8 less than the average population and the standard deviation of the population is about 1 less than the standard deviation of the sample.
B.
Suppose that the sample size n = 100 and the population proportion p = 0.95.
- Does the sample proportion p have approximately a normal distribution? Explain.
Yes, the sample proportion will have approximately a normal distribution because:
q = 1 – p
q = 1 – 0.95 = 0.05
np = 100*0.95 = 95
nq = 100*0.05 = 5
In order to have a normal distribution, np and nq have to be greater than or equal to 5. As you can see, the sample proportion meets this criteria.
- What is the smallest value of n for which the sampling distribution of p is approximately normal?
Because p is 0.95, making q = 0.05, n can be no smaller than 100 because nq can be no smaller than 5.
The sample mean from a group of observations is an estimate of the population mean μ . Given a sample of size n, consider n independent random variables X1, X2, …, Xn, each corresponding to one randomly selected observation. Each of these variables has the distribution of the population, with mean μ and standard deviation σ .
A. Population mean= (8+14+16+10+11)/5 = 11.8
B. Sample of size n =
> sample(x, size = 4)
[1] 10 14 8 16
C. Mean of sample distribution: ____
sample 1= 10/4 = 2.5
sample 2= 14/4 = 3.5
sample 3 = 8/4 = 2
sample 4 = 16/4 = 4
And Standard Error Qm=Q/square root of n=4.4/square root of 5=
D. I am looking for table with the following variables X, x=u, and
(x-u)^2
C.
From our textbook, Chapter 2 Probability Exercises # 2.4
Simulated coin tossing is probability better done using function called rbinom than using function called sample. Explain.
This is because rbinom simulates the outcomes of the bernoulli distribution. The function requires 3 parameters. For a coin toss, the first parameter is telling R how many tosses to perform. The second parameter is the “size”. This parameter allows you to take x amount of trials and add them up. The third parameter is the probability given to the coin. So, for a coin toss you would want it set to 0.5.
Here is an example of code if we wanted to toss a coin 5 times and record the results(1 and 0 stand for heads and tails):
> rbinom(5, 1, 0.5)
[1] 0 1 1 1 1
Now here is an example of code if we wanted to add the result of 5 separate trials together:
> rbinom(1, 5, 0.5)
[1] 3
Leave a comment