Table of Contents
- Null & Alternative Hypotheses
- Hypothesis Testing Workflow
- One-sample t-test
- Two-sample t-test
- p-value
- Significance Level (α)
- Type I & Type II Errors
- Confidence Intervals
- Choosing the Correct Test
- Complete Python Examples
- Interview Questions
- Summary
1. Null & Alternative Hypotheses
A hypothesis is an assumption about a population parameter. There are always two hypotheses.Null Hypothesis (H₀)
The null hypothesis assumes no effect, no difference, or no relationship. Examples:- Average salary = ₹50,000
- New medicine is not better than old medicine.
- Two algorithms have equal accuracy.
- μ = population mean
Alternative Hypothesis (H₁ or Hₐ)
The alternative hypothesis represents what we want to prove. ExamplesTypes of Alternative Hypotheses
Two-tailed
Testing for any difference.Right-tailed
Testing if value is greater.Left-tailed
Testing if value is smaller.Hypothesis Testing Workflow
2. One-Sample t-test
Used when comparing one sample mean against a known population value.Example
A company claims average battery life is 10 hours. Sample:Formula
where- x̄ = sample mean
- μ = population mean
- s = sample standard deviation
- n = sample size
Python Example
Interpretation
If3. Two-Sample t-test
Used to compare means of two independent groups. Example Do students using Method A score differently than students using Method B?Sample Method A
Python
Equal Variance Assumption
If variances are unequalDifference Between One-Sample and Two-Sample t-test
4. p-value
The p-value measures how likely the observed data would occur if the null hypothesis were true. It is not the probability that the null hypothesis is true.Interpretation
Example
Another Example
5. Significance Level (α)
The significance level is the threshold for deciding whether to reject the null hypothesis. Common choicesDecision Rule
6. Type I & Type II Errors
Type I Error (False Positive)
Rejecting a true null hypothesis. Reality:Type II Error (False Negative)
Failing to reject a false null hypothesis. RealityStatistical Power
PowerError Table
7. Confidence Intervals
A confidence interval gives a range where the true population parameter is likely to lie. ExampleFormula
x̄= Sample meant*= Critical t-value (depends on confidence level and degrees of freedom)s= Sample standard deviationn= Sample size
Python Example
Interpretation
If the confidence interval contains the hypothesized valueChoosing the Correct Test
Complete Python Example
Interview Questions
What is the null hypothesis?
A statement that assumes there is no difference or no effect.What does a p-value represent?
The probability of observing results at least as extreme as those obtained if the null hypothesis is true.Why use a t-test?
To compare means when the population standard deviation is unknown.Difference between α and p-value?
- α is chosen before the experiment (decision threshold).
- p-value is computed from the observed sample data.
What is a 95% confidence interval?
An interval produced by a method that, over many repeated samples, would contain the true population parameter about 95% of the time.Summary
Key Takeaways
- Start by defining H₀ and H₁.
- Choose the correct statistical test based on the data.
- Compare the p-value with α to make a decision.
- Understand the risks of Type I and Type II errors.
- Use confidence intervals to estimate plausible values for the population parameter.
- Report both the test result and the confidence interval for a more complete statistical interpretation.