t -test

 

What is a t-test?

A t-test is a statistical hypothesis test used to determine whether there is a significant difference between the means of two groups.

It is commonly used when:

  • Sample sizes are small

  • Population standard deviation is unknown

  • The data is approximately normally distributed


🧪 Types of t-tests

There are three main types of t-tests:

1. One-Sample t-test

Compares the mean of a single sample to a known value (often a population mean).

Example: Is the average IQ of a group of students different from 100?


2. Two-Sample t-test (Independent)

Compares the means of two independent groups.

Example: Are the exam scores of male and female students significantly different?


3. Paired Sample t-test (Dependent)

Compares means of the same group at two different times (or matched pairs).

Example: Did students improve after a training session?


📐 Assumptions of the t-test

  • Data is continuous

  • Data is normally distributed (or approximately normal)

  • Observations are independent

  • Variances are equal for independent samples (unless using Welch's t-test)


🔢 Formulas

✅ One-Sample t-test:

t=xˉμ0s/nt = \frac{\bar{x} - \mu_0}{s / \sqrt{n}}
  • xˉ\bar{x} = sample mean

  • μ0\mu_0 = population mean

  • ss = sample standard deviation

  • nn = sample size


✅ Two-Sample t-test:

t=xˉ1xˉ2sp1n1+1n2t = \frac{\bar{x}_1 - \bar{x}_2}{s_p \sqrt{ \frac{1}{n_1} + \frac{1}{n_2} }}

Where sps_p= pooled standard deviation:

sp=(n11)s12+(n21)s22n1+n22s_p = \sqrt{ \frac{(n_1 - 1)s_1^2 + (n_2 - 1)s_2^2}{n_1 + n_2 - 2} }


✅ Paired Sample t-test:

t=dˉsd/nt = \frac{\bar{d}}{s_d / \sqrt{n}}
  • dˉ\bar{d} = mean of the differences

  • sds_d = standard deviation of the differences

  • nn= number of pairs


Examples

Example 1: One-Sample t-test

Problem: A teacher claims that the average score in her class is 75. A sample of 10 students has a mean score of 72 with a standard deviation of 5. Is her claim valid?

Solution:

t=72755/10=31.581.90t = \frac{72 - 75}{5 / \sqrt{10}} = \frac{-3}{1.58} ≈ -1.90

Using a t-table with df = 9, at α = 0.05, critical t ≈ ±2.262.
Since -1.90 > -2.262, we fail to reject the null hypothesis.

✅ Conclusion: No significant difference.


Example 2: Independent Two-Sample t-test

Problem: Two sections of a class scored as follows:

  • Section A: mean = 70, sd = 4, n = 10

  • Section B: mean = 75, sd = 5, n = 10

Is there a significant difference in scores?

Solution:

  1. Calculate pooled standard deviation:

sp=(9)(42)+(9)(52)18=144+22518=20.54.53s_p = \sqrt{ \frac{(9)(4^2) + (9)(5^2)}{18} } = \sqrt{ \frac{144 + 225}{18} } = \sqrt{20.5} ≈ 4.53
  1. Compute t-statistic:

t=70754.53110+110=54.530.44752.022.48t = \frac{70 - 75}{4.53 \cdot \sqrt{\frac{1}{10} + \frac{1}{10}}} = \frac{-5}{4.53 \cdot 0.447} ≈ \frac{-5}{2.02} ≈ -2.48

Degrees of freedom = 18. Critical t ≈ ±2.101 at α = 0.05.

✅ Since -2.48 < -2.101 → Reject null hypothesis

✔️ Conclusion: Significant difference in scores.


Example 3: Paired Sample t-test

Problem: Students took a mock test and then a final test. Scores:

StudentMockFinal
A6570
B6872
C7075
D6066
E6265

Compute differences: [5, 4, 5, 6, 3]

Mean difference = 4.6
Standard deviation of difference ≈ 1.14
n = 5

t=4.61.14/54.60.519.02t = \frac{4.6}{1.14 / \sqrt{5}} ≈ \frac{4.6}{0.51} ≈ 9.02

df = 4, critical t ≈ 2.776.
Since 9.02 > 2.776 → Reject null hypothesis

✅ Conclusion: Significant improvement.


💡 When to use which t-test?

ScenarioTest Type
Compare one sample with known mean    One-sample t-test
Compare two unrelated group means    Two-sample (independent)
Compare two related (paired) samples    Paired sample t-test

Comments

Popular posts from this blog

Statistical Methods Lab ( R Language) PCCBL308 Semester 3 KTU BTech CB 2024 Scheme - Dr Binu V P

Statistical Methods Lab ( R Language) PCCBL308 Course Details and Syllabus