Question2

Given sample size = 10

Sample mean = 75.92

Sample Standard Deviation = 0.5

Alpha = 0.02

sample_size <- 10
sample_mean <- 75.92
sample_sd <- 0.5
alpha <- (1-.98)/2
df <- sample_size - 1

t_critical <- qt(alpha,df,lower.tail = FALSE)
margin_of_error <- t_critical * (sample_sd / sqrt(sample_size))
CI_lower <- sample_mean - margin_of_error
CI_upper <- sample_mean + margin_of_error

cat("98% Confidence Interval:", CI_lower, ",", CI_upper, "\n")
## 98% Confidence Interval: 75.47389 , 76.36611

Given sample size = 16

sample mean x = 1.053

Population Standard Deviation = 0.058

Z-alpha = 1-0.99 = 0.01

sample_size4 <- 16
sample_mean4 <- 1.053
Population_sd4 <- 0.058
alpha4 <- 1 - 0.99

z_value4 <- qnorm(alpha4)
standard_error4 <- Population_sd4 / sqrt(sample_size4)
margin_of_error4 <- z_value4 * standard_error4
CI_lower4 <- sample_mean4 + margin_of_error4

CI_upper4 <- '∞'

cat("99% onesided Confidence Interval: (",CI_lower4 , ",",CI_upper4, ")\n")
## 99% onesided Confidence Interval: ( 1.019268 , ∞ )

Alpha = 1-.95/2

scores6 <- c(84, 93, 137, 116, 116, 80, 103, 90, 106, 109, 
            95, 98, 106, 121, 111, 110, 91, 92, 113, 103)

n <- length(scores6)

sample_mean6 <- mean(scores6)

sample_sd6 <- sd(scores6)

confidence_level6 <- 0.95

df6 <- n - 1

# Critical value (two-tailed t-distribution)
t_critical6 <- qt(1 - (1 - confidence_level6) / 2, df6) 

# Standard error
standard_error6 <- sample_sd6 / sqrt(n)

# Margin of error
margin_of_error6 <- t_critical6 * standard_error6

# Confidence interval
CI_lower6 <- sample_mean6 - margin_of_error6
CI_upper6 <- sample_mean6 + margin_of_error6

cat("95% Two sided Confidence Interval: (",CI_lower6 , ",",CI_upper6, ")\n")
## 95% Two sided Confidence Interval: ( 97.26837 , 110.1316 )
cat("Population Mean : ",sample_mean6)
## Population Mean :  103.7

Given Sample Size = 6

Alpha = 0.05

Since we want to try and prove that the sample mean is GREATER… we will use a RIGHT sided t test:

H0:mu <= 2

H1:mu > 2

pumps_sample8 <- c(2.0, 1.3, 6.0, 1.9, 5.1, 4.0)

pumps_sample8
## [1] 2.0 1.3 6.0 1.9 5.1 4.0
n <- length(pumps_sample8)

alpha <- .05

sample_sd <- sd(pumps_sample8)

sample_mean<- mean(pumps_sample8)

shapiro.test(pumps_sample8) 
## 
##  Shapiro-Wilk normality test
## 
## data:  pumps_sample8
## W = 0.90096, p-value = 0.3796
t_test2 <- t.test(pumps_sample8, mu = 2, alternative = "greater", conf.level=.95)

t_score2 <- qt(p=.05, df=5,lower.tail=F) #the t score

t_test2
## 
##  One Sample t-test
## 
## data:  pumps_sample8
## t = 1.7555, df = 5, p-value = 0.06977
## alternative hypothesis: true mean is greater than 2
## 95 percent confidence interval:
##  1.795475      Inf
## sample estimates:
## mean of x 
##  3.383333
t_score2
## [1] 2.015048

Conclusion : At the value of alpha = 0.05 ,The t statistic (1.7555) is < the t score (2.015048), so we fail to reject the null as it does not fall in the reject range.

Additionally, the p-value of .06977 is > alpha of .05 which further supports that we fail to reject the null.

We conclude that we FAIL TO REJECT the null hypothesis, that the mean life span is less than or equal to 2, so we don’t have enough evidence to claim that the life span is greater than 2. This makes sense if we look at the lower confidence bound… it implies that with 95% confidence, our population mean could be as low as 1.795.

Given sample size = 14

alpha = 0.05

Ho: mu = 7 Ha: mu != 7

meter_readings_sample <- c(7.01, 7.04, 6.97,7.00,6.99,6.97, 7.04, 7.04, 7.01, 7.00, 6.99, 7.04, 7.07, 6.97)


n <- length(meter_readings_sample)
n
## [1] 14
alpha <- .05

sample_sd8 <- sd(meter_readings_sample)

sample_mean8<- mean(meter_readings_sample)

shapiro.test(meter_readings_sample) 
## 
##  Shapiro-Wilk normality test
## 
## data:  meter_readings_sample
## W = 0.91603, p-value = 0.1927
t_test8<- t.test(meter_readings_sample, mu = 7, alternative = "two.sided", conf.level=.95)

t_score8 <- qt(p=.05/2, df=13,lower.tail=FALSE) 
t_test8
## 
##  One Sample t-test
## 
## data:  meter_readings_sample
## t = 1.1832, df = 13, p-value = 0.2579
## alternative hypothesis: true mean is not equal to 7
## 95 percent confidence interval:
##  6.991742 7.028258
## sample estimates:
## mean of x 
##      7.01
t_score8
## [1] 2.160369

Conclusion : At the alpha value 0.05 , We see the t statistic is falling within the acceptance range (t score of 2.160369 , -2.160369) so we FAIL TO REJECT the null hypothesis. Therefore, from our hypothesis statement, we can say there isn’t enough evidence to claim that the calibration is incorrect (so it’s calibrated correctly). Again, we cannot say it is proven that mu=7.0, but we can say it is plausible.

Additionally the p-value is larger than the alpha of .05, so further evidence to support us to be able to NOT reject the null.Hence mu is plausable but not true

Given sampleA_mean = 5.38

sampleB_Mean = 5.92

SampleA_size = 10

SampleB_Size = 12

sampleA_SD = 1.59

SampleB_SD = 0.83

a. Calculate a 95% Confidence Interval for the mean difference.

sampleA_mean <- 5.38
sampleA_SD <- 1.59
SampleA_size <- 10
sampleB_mean <- 5.92
sampleB_SD <- 0.83
SampleB_size <- 12

# Pooled standard deviation
s_p <- sqrt(((SampleA_size - 1) * sampleA_SD^2 + (SampleB_size - 1) * sampleB_SD^2) / (SampleA_size + SampleB_size - 2))

# Degrees of freedom
df12 <- SampleA_size + SampleB_size - 2

# Critical t value for 95% confidence level
t_critical <- qt(0.975, df)

# Standard error of the difference in means
se_diff <- s_p * sqrt(1/SampleA_size + 1/SampleB_size)

# Difference in means
mean_diff <- sampleA_mean - sampleB_mean

# Confidence interval
lower_bound <- mean_diff - t_critical * se_diff
upper_bound <- mean_diff + t_critical * se_diff

cat("95% Confidence Interval for the mean difference:", lower_bound, "to", upper_bound, "\n")
## 95% Confidence Interval for the mean difference: -1.732808 to 0.6528077

b. Hypothesis test :

Ho: muA = muB Ha: muA != muB

# Test statistic
t_statistic <- mean_diff / se_diff

# p-value
df12 <- SampleA_size + SampleB_size - 2
p_value <- 2 * pt(-abs(t_statistic), df12)

cat("Test Statistic:", t_statistic, "\n")
## Test Statistic: -1.024109
cat("p-value:", p_value, "\n")
## p-value: 0.3180121
if (p_value < 0.10) {
  cat("Reject the null hypothesis at the 0.10 significance level.\n")
} else {
  cat("Fail to reject the null hypothesis at the 0.10 significance level.\n")
}
## Fail to reject the null hypothesis at the 0.10 significance level.

Conclusion : At the alpha value 0.10 , We see the t statistic is falling within the acceptance range (t score of -1.639903 to 0.5599029) so we FAIL TO REJECT the null hypothesis. Therefore, from our hypothesis statement, we can say there isn’t enough evidence to claim that the mean amount of water dispensed by machine A is different from machine B. Again, we cannot say it is proven that muA = muB, but we can say it is plausible.

Additionally the p-value is larger than the alpha of .10, so further evidence to support us to be able to NOT reject the null.Hence muA=muB is plausable but not true

#### Given Alpha = 0.05

H0 = muNormoxia = muHypoxia Ha = muNormoxia != muHypoxia

normoxia <- c(3.45, 3.09, 3.09, 2.65, 2.49, 2.33, 2.28, 2.24, 2.17, 1.34)
hypoxia <- c(6.37, 5.69, 5.58, 5.27, 5.11, 4.88, 4.68, 3.50)

# Perform two-sample t-test
t_test_result <- t.test(normoxia, hypoxia, var.equal = TRUE)

# Print the results
cat("t-test result:\n")
## t-test result:
print(t_test_result)
## 
##  Two Sample t-test
## 
## data:  normoxia and hypoxia
## t = -7.7146, df = 16, p-value = 8.855e-07
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -3.342503 -1.901497
## sample estimates:
## mean of x mean of y 
##     2.513     5.135

Conclusion : At the alpha value 0.05 , the p-value is significantly smaller than the alpha(0.05) hence we reject the null hypothesis.With these results we got the strong evidence that the mean MBF is significantly different for normoxia and hypoxia.

mean thickness of the current process = .0020

mean thickness of the new process = .0022

sd of current process = 0.0005

sd of current process = 0.0003

a. New process result in Greater thickness

h0 : muNew <= muCurrent ha : muNew > muCurrent

x1 <- 0.0020  
s1 <- 0.0005  
x2 <- 0.0022  
s2 <- 0.0003  
n1 <- 30
n2 <- 30  

# Pooled standard deviation
sp16 <- sqrt(((n1 - 1) * s1^2 + (n2 - 1) * s2^2) / (n1 + n2 - 2))
cat("Pooled Standard deviation",sp16,"\n")
## Pooled Standard deviation 0.0004123106
# Test statistic for one-tailed test
t_stat16 <- (x1 - x2) / (sp16 * sqrt(2 / n1))
cat("one-tailed test statistic",t_stat16,"\n")
## one-tailed test statistic -1.878673
# Degrees of freedom
df16 <- n1 + n2 - 2
cat("Degree's of Freedom",df16,"\n")
## Degree's of Freedom 58
# Critical value for one-tailed test at alpha = 0.05
alpha16 <- 0.05
t_critical16 <- qt(alpha16, df16, lower.tail = FALSE)
cat("Critical t-value",t_critical16,"\n")
## Critical t-value 1.671553
# Conclusion of the hypothesis test
if (t_stat16 < -t_critical16) {
  cat("Reject the null hypothesis: the new process results in a greater thickness of nickel.\n")
} else {
  cat("Fail to reject the null hypothesis: there is not enough evidence to conclude that the new process results in a greater thickness of nickel.\n")
}
## Reject the null hypothesis: the new process results in a greater thickness of nickel.

Conclusion : At the alpha value 0.05 , We see the t statistic is falling in the rejection range so we REJECT the null hypothesis. Therefore, from our hypothesis statement, we can say there is strong evidence to claim that the mean thickness of nickel in new process is greater from current process . Again, we cannot say it is proven that muNew > muCurrent, but we can say it is plausible.

Determine the 99% confidence interval for the difference in the means.

# 99% confidence interval for the difference in means
alpha16b <- 1 - 0.99
t_critical_16b <- qt(alpha16b / 2, df16, lower.tail = FALSE)
cat("99% CI Critical t-value",t_critical_16b,"\n")
## 99% CI Critical t-value 2.663287
margin_of_error16b <- t_critical_16b * sp16 * sqrt(2 / n1)
cat("99% CI Margi of error",margin_of_error16b,"\n")
## 99% CI Margi of error 0.0002835285
lower_bound16b <- (x1 - x2) - margin_of_error16b
upper_bound16b <- (x1 - x2) + margin_of_error16b

cat(sprintf("99%% confidence interval for the difference in means: (%.6f, %.6f)\n", lower_bound16b, upper_bound16b))
## 99% confidence interval for the difference in means: (-0.000484, 0.000084)

Given population mean = 180

Sample mean = 174.7

Sample Size = 50

Population SD = 14

alpha = 0.05

H0 : mu >= 180 Ha : mu < 180

mu <- 180.0  
sigma <- 14.0  
n <- 50 
x_bar <- 174.7 
alpha <- 0.05  

# Calculate the test statistic
z <- (x_bar - mu) / (sigma / sqrt(n))
cat("Z-test statistic value",z,"\n")
## Z-test statistic value -2.676904
# Critical value for one-tailed test at alpha = 0.05
z_critical <- qnorm(alpha, lower.tail = TRUE)
cat("Z-Critical value",z_critical,"\n")
## Z-Critical value -1.644854
# Make a decision
if (z < z_critical) {
  cat("Reject the null hypothesis: The mean height of Clarkson students is significantly less than 180.0 cm.\n")
} else {
  cat("Fail to reject the null hypothesis: There is not enough evidence to suggest that the mean height of Clarkson students is less than 180.0 cm.\n")
}
## Reject the null hypothesis: The mean height of Clarkson students is significantly less than 180.0 cm.

Conclusion : At the alpha value 0.05 , the Z-stat values falls in the rejection region ,so we reject the null hypothesis.Therefore, from our hypothesis statement, we can say there is strong evidence to claim that the mean height of students in clarkson is significantly less than 180.0 cm.