How do I find the confidence interval? 2 sample t-test

30 Views Asked by At

enter image description here

Specifically, the last question on this page.

I do not know how to even get started. I have tried using an online calculator, but that did not work, and none of my course notes indicate how to solve this. I do not even know what the name of this problem is. The answer I put in last was using an online calculator - if a calculator is getting it wrong, I think it indicates a pretty profound misunderstanding on my part.

Here is what I have so far:

mean of A: 14.6684615385

mean of B: 15.4876923077

When I look up in the t table for 24 df and 95% confidence interval, I get a value of 2.064. I do not know how to use this value.

I ended up implementing a python script to solve it using formulas given to me. It generated an incorrect answer. See here:

import numpy
import scipy.stats
import math

def sample_stdev(list):
    sos = 0
    avg = numpy.mean(list)

    for i in list:
        sos += (i - avg)**2

    s = math.sqrt(1.00 / (len(list) - 1.00) * sos)
    return s

B = [16.34,16.88,15.10,14.30,17.31,15.56,13.84,16.14,16.10,14.81,13.39,12.29,19.28]
A = [19.06,13.94,11.52,16.33,12.61,12.20,14.60,14.39,17.70,11.85,13.00,18.49,15.00]


sa = sample_stdev(A)
sb = sample_stdev(B)

sp = math.sqrt(((12.00) * sb**2.00 + (12) * sa**2) / 24.00)
print(sp)
print math.sqrt(2.00/13.00)

ans = (15.4876923077 - 14.6684615385) + (2.064 * sp * math.sqrt(2.00/13.00))

# Upper bound
print(ans)

# Lower bound
ans = (15.4876923077 - 14.6684615385) - (2.064 * sp * math.sqrt(2.00/13.00))
print(ans)