Module 6 assignment

Daniel Tafmizi

Lis 4273

Dr. Ajani 

February 18, 2024

Module 6 Assignment

#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


iceCream <- c(8,14,16,10,11) #Creates numerical vector


#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.


randomSample <- sample(iceCream, 2) #Gets random sample of two values 10 & 8 were chosen


# c. Compute the mean and standard deviation of your sample.


mean(randomSample) # mean of sample = 9

sd(randomSample) # standard deviation of sample = 1.414214


mean(iceCream) # mean of population = 11.8

sd(iceCream) # standard deviation of population = 3.193744


#d. Compare the Mean and Standard deviation of your sample to the entire population of this set (8,14, 16, 10, 11).


# The random sample taken chose the two lowest values of the population. Because of this,

#both the mean of the sample held lower values then the population mean. The SD of the sample

# was lower because the values were closer to eachother than in the population.


#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.


x <- rnorm(100, .95)


qqnorm(x)

qqline(x)


# The data lies close to the line, thus it has a normal distribution


#What is the smallest value of n for which the sampling distribution of p is approximately normal? 


# The central limit theorem states that a minimum of 30 samples is required to test for normal distribution.


# a) mean pop =    11.8

# b) sample size = 100

# c) mean sample = 11.80216 

# D) standard error = 1.428286

n <- 100


sample_means = rep(NA, n)


for (i in 1: n){

  sample_means[i] = mean(rnorm(5, mean = 11.8, sd = 3.193744))

}

head(sample_means)

hist(sample_means)

mean(sample_means)


print(sd(iceCream)/sqrt(length(iceCream)))


#rbinom interprets the number of successes in a size trial which is useful for statistical analysis

#sample is a modeling function that allows for a visual representation of each result

#Neither option is better at simulating a coin toss, they just present the data differently. 

#Each one has its own specific use in the world of statistics.

 

Comments

Popular posts from this blog

Final Project 4930

Module 10 Assignment

Module 4 Assignment