Two sample t test
T test for two independent sample T test for two depend samples
T test for two independent sample
A t-test for independent samples, also known as an independent samples t-test or two-
sample t-test, is a statistical method used to determine if there is a statistically
significant difference between the means of two independent groups. This test is
frequently used to analyze data from A/B tests or to compare the means of two
unrelated groups.
Key Concepts:
• Independent Groups:
The two groups being compared must be independent, meaning there's no relationship
or pairing between the individuals or data points in each group.
• Null Hypothesis:
The null hypothesis assumes that there is no difference between the means of the two
groups in the population. Means equal
• Alternative Hypothesis:
The alternative hypothesis proposes that there is a significant difference between the
means of the two groups.
• t-statistic:
The t-test calculates a t-statistic, which is a measure of the difference between the
sample means relative to the variability within the groups.
• p-value:
The t-test also produces a p-value, which indicates the probability of observing the
obtained results (or more extreme results) if the null hypothesis were true.
Assumptions:
• Independence of Observations: Data points within each group should be
independent of each other.
• Normality: The data within each group should be approximately normally
distributed.
• Homogeneity of Variance: The variances of the two groups should be
roughly equal.
Variance s1 ~ variance s2
• Random Sampling: The samples should be randomly selected from the
populations.
• The variance of the underlying population represented by sample 1 is
equal to the variance of the underlying population represented by sample
2
• Distribution of data underlying population which each of the sample is
derived is normal
Variance s 1 # variance s2
Variance s1 ~ variance s2
how to determine the sample is independent or depend sample in the question or
scenario
• Independent Samples:
• Definition: Two samples are independent if the selection of
individuals in one sample doesn't affect the selection of
individuals in the other sample.
• Example: Comparing the heights of randomly selected students
from two different schools.
• Key Characteristics: The samples are drawn from different
groups, and there's no inherent relationship between the
individuals in each group.
• Dependent Samples (Paired Samples):
• Definition: Two samples are dependent if the selection of
individuals in one sample is related to the selection of individuals
in the other sample.
• Example: Measuring the blood pressure of the same group of
people before and after taking a medication.
• Key Characteristics: The samples often involve repeated
measurements on the same individuals or matched pairs.
[Link]
T test for two depend samples
A t-test for two dependent samples (also called a paired t-test) is used
when you are comparing the means of two related groups. This typically
applies in "before-and-after" scenarios or when the same subjects are tested
under two conditions.
When to Use:
• Same participants measured twice (e.g., pre-test/post-test).
• Matched pairs (e.g., twins, matched individuals).
Steps to Perform Paired t-test:
1. State Hypotheses:
o Null Hypothesis (H₀): There is no difference between the means
of the two related groups.
o Alternative Hypothesis (H₁): There is a significant difference
between the means.
2. Calculate the Differences (D):
o For each pair, subtract one score from the other:
D=X2−X1D = X_2 - X_1D=X2−X1
o Where X2X_2X2 and X1X_1X1 are the paired observations.
3. Compute the Mean and Standard Deviation of Differences:
o Mean of differences:
D‾=∑Dn\overline{D} = \frac{\sum D}{n}D=n∑D
o Standard deviation of differences:
SD=∑(D−D‾)2n−1S_D = \sqrt{\frac{\sum (D - \overline{D})^2}{n-1}}SD
=n−1∑(D−D)2
4. Calculate t-statistic:
t=D‾SD/nt = \frac{\overline{D}}{S_D / \sqrt{n}}t=SD/nD
5. Determine Degrees of Freedom (df):
df=n−1df = n - 1df=n−1
6. Compare t-statistic to critical t-value (from the t-distribution table at
your chosen significance level, typically 0.05) to decide whether to
reject H₀.
Example:
Subject Before (X₁) After (X₂) Difference (D)
1 85 89 4
2 78 84 6
3 90 88 -2
4 70 75 5
5 80 82 2
• Calculate mean of D, SD of D, t-statistic, then compare.
Assumptions:
• Data are continuous.
• Paired observations are randomly sampled.
• Differences are approximately normally distributed.