Module #6 Assignment

 A. 

First, let's address the calculations for the populations and sampla data

# Population data 

population <- c(8, 14, 16, 10, 11)

# a. Compute the mean of the population mean

mean_population <- mean(population)

mean_population 


Now, for selecting a random sample of size 2 out of the five members, you can use 'sample()' function: 

# b. Select a random sample of size 2

sample_size <- 2

random_sample <- sample(population, size = sample_size) 

random_sample 

Next, compute the mean and standard deviation of your sample: 

mean_sample <-  mean(random_sample) 

sd_sample <-  sd(random_sample) 

mean_sample 

sd_sample 

Finally, compare the mean and standard deviation of your sample to the entire population: 

#d. Compare the Mean and Standard deviation of your sample to the entire population 

mean_comparison <- mean_sample == mean_population 

sd_comparison <-  sd_sample == sd(population)

mean_comparison 

sd_comparison


B. 

1. To determine whether the sample proportion p has approximately a normal distribution, we need to check if both np and nq are greater than or equal to 5. 

# Given valubes 

n <- 100 

p <- 0.95 

# Calculate np and nq

np <- n * p 

nq <- n * (1-p) 

np 

nq 

If both np and nq are greater than or equal to 5, then the sample proportion p has approximately a normal distribution. You can check this by comparing the values of np and nq to 5. 

2. 

To find the smallest value of n which the sampling distribution of p os approximately normal, you need to solve for n when np and nq are both equal to or greater than 5. You can use trail and error or create a loop to find this value. Start with a small value of n and increment it until both np and nq are at least 5. 

C. 

The 'rbinom' function generates random binomial variates, which is more suitable for simulating coin tossing where there are two possible outcomes (heads and tails) with known probabilities (p and q). The 'sample' function is more general and doesn't take into account the specific probabilities associated with coin tossing.  

Comments

Popular posts from this blog

Final Project [LIS4317]

Module # 7 assignment (Visual Analytics)

Module # 8 Input/Output, string manipulation and plyr package