Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

Hypothesis Testing & Confidence Intervals

Lesson 14 of 37 in the free Data Science notes on Siksha Sarovar, written by Rohit Jangra.

Hypothesis Testing

Hypothesis Testing is a structured, statistical method for making decisions about a population based on sample data. It helps answer questions like: "Is the difference in performance between Group A and Group B real, or just due to random chance?"

It is the backbone of A/B testing, clinical trials, and scientific research.

---

The Hypothesis Testing Framework

Step 1: State the Hypotheses

  • Null Hypothesis (Hâ‚€): The "default" or "status quo" statement. It assumes there is no effect or no difference.
  • Example: "The new drug has no effect on blood pressure."
  • Alternative Hypothesis (H₁ or Hₐ): The statement we are trying to find evidence for. It assumes there is an effect or difference.
  • Example: "The new drug reduces blood pressure."

Step 2: Choose Significance Level (α)

  • The significance level is the threshold for rejection. Common values:
  • α = 0.05 (5%) — Most common
  • α = 0.01 (1%) — More strict
  • It represents the probability of rejecting Hâ‚€ when it is actually true (Type I Error).

Step 3: Collect Data & Calculate Test Statistic

  • Perform the experiment or survey.
  • Calculate the appropriate test statistic (Z-score, t-score, chi-squared, etc.) based on the data.

Step 4: Calculate the p-value

  • The p-value is the probability of observing the test results (or more extreme) assuming Hâ‚€ is true.
  • Small p-value → Strong evidence against Hâ‚€.

Step 5: Make a Decision

ConditionDecision
p-value ≤ αReject H₀ — The result is "statistically significant"
p-value > αFail to Reject H₀ — Not enough evidence to support H₁

Important: "Fail to reject Hâ‚€" does NOT mean Hâ‚€ is true. It means we don't have enough evidence to prove it wrong.

---

Types of Errors

Error TypeNameWhat HappenedConsequence
Type IFalse PositiveRejected Hâ‚€ when it was trueConcluded there's an effect when there isn't one
Type IIFalse NegativeFailed to reject Hâ‚€ when it was falseMissed a real effect

Analogy:

  • Type I Error: Fire alarm goes off, but there is no fire (false alarm).
  • Type II Error: Fire is burning, but the alarm doesn't go off (missed fire).

Relationship:

  • Decreasing Type I Error (making α smaller) → Increases Type II Error risk.
  • There is always a trade-off between the two.

---

Common Statistical Tests

TestWhen to UseExample
Z-TestLarge sample (n > 30), known population varianceComparing mean height to national average
t-TestSmall sample (n < 30), unknown population varianceComparing test scores of two small classes
Chi-Squared TestCategorical data (proportions)Is there a relationship between gender and product preference?
ANOVAComparing means of 3+ groupsIs there a difference in sales across 4 regions?
F-TestComparing variances of two groupsAre production line variances equal?

---

One-Tailed vs Two-Tailed Tests

Test TypeHypothesisWhen to Use
One-TailedH₁: μ > μ₀ or H₁: μ < μ₀You predict the direction of the effect ("Drug reduces BP")
Two-TailedH₁: μ ≠ μ₀You just want to know if there's any difference ("Drug changes BP")

---

Confidence Intervals

Definition: A confidence interval (CI) is a range of values within which we can be "confident" the true population parameter lies.

Formula (for population mean): CI = x̄ ± Z × (σ / √n)

Where:

  • xÌ„ = Sample mean
  • Z = Z-score corresponding to desired confidence level
  • σ = Standard deviation
  • n = Sample size

Common Confidence Levels:

Confidence LevelZ-ScoreInterpretation
90%1.645We are 90% confident the true mean is in this range
95%1.96We are 95% confident the true mean is in this range
99%2.576We are 99% confident the true mean is in this range

---

Confidence Interval — Worked Example

A sample of 100 students has a mean exam score of 72 with σ = 10. Calculate the 95% confidence interval. CI = 72 ± 1.96 × (10 / √100) CI = 72 ± 1.96 × 1 CI = 72 ± 1.96 CI = [70.04, 73.96] Interpretation: We are 95% confident that the true population mean exam score lies between 70.04 and 73.96.

---

Key Relationships

ConceptConnection to Data Science
Hypothesis TestingPowers A/B Testing (website optimization), clinical trials, feature significance
p-valueUsed to determine if model coefficients are statistically significant
Confidence IntervalProvides a range estimate instead of a single point; used in polling, surveys
Type I/II ErrorsCritical in medical diagnostics and fraud detection

Confidence Interval vs Hypothesis Testing

FeatureConfidence IntervalHypothesis Testing
PurposeEstimate a range for the parameterTest a specific claim about the parameter
OutputA range (e.g., [70.04, 73.96])Accept or Reject decision
InformationMore informative (range + direction)Less informative (binary decision)
RelationshipIf the CI does not contain the null value, reject H₀If p-value ≤ α, reject H₀

Summary

  • Hypothesis testing is a structured method for making statistical decisions from data.
  • The null hypothesis (Hâ‚€) is the default; the alternative (H₁) is what we want to prove.
  • p-value measures the strength of evidence against Hâ‚€.
  • Type I Error (false positive) and Type II Error (false negative) represent the risks of wrong decisions.
  • Confidence intervals provide a range estimate for a parameter at a given confidence level.
  • A 95% CI means: if we repeated the experiment 100 times, approximately 95 of those intervals would contain the true value.