a) Generate 50 values from X ~ N (μX= 25, σX = 4) and 50 values from Y ~ N (μY= 25, σY = 4). Use a t-test to test for equality of the means.
c) Repeat part (a) 2500 times, and retain the p-value for each of the 2500 tests. Each repetition should generate a new sample for x and a new sample for y. DO NOT PRINT the p-values. DO NOT use a loop.
I solved for Part A on one rnorm
sample but I'm confused on where to start to get 2500 different random samples of x and 2500 different random samples of y to get 2500 different p-values.
I also don't know how to make sure to write my code so that my professor will get the same answers I did. I tried setting the seed but that only makes it so the p-values are all the same using my code above.
# Part A
set.seed(1081)
x = rnorm(50,25,4)
y = rnorm(50,25,4)
t.test(x,y)
#Part B
#The p-value is 0.3752.
#We do not reject the null hypothesis.
#Part C
x1 = sample(x, 2500, replace = T)
y1 = sample(y, 2500, replace = T)
pval = sample(t.test(x1,y1)$p.value, 2500, replace = T)