Sampling, estimation and hypothesis testing — Unit 4 Notes (Probability and Statistics for Computing)

BAS401 · Unit 4

Sampling, estimation and hypothesis testing notes — Unit 4

Free unit-wise study notes on sampling, estimation and hypothesis testing for Probability and Statistics for Computing, Semester 4 of B.Tech — Computer Science & Engineering — key concepts, examples, important questions and a revision checklist for semester exams.

The science of inferential statistics. Covers the Central Limit Theorem, unbiased Estimation, Confidence Intervals, and the formal procedure of Hypothesis Testing (Null vs Alternate, Type I/II Errors, p-values, Z-tests, and t-tests).

Notebook — 11 pages

Page 1

Wink Notes

B.Tech CSE — 4th Semester

Probability and Statistics

Unit - 4

1. Introduction to Inferential Statistics

Up until now, probability theory assumed we knew the exact mathematical parameters (like the exact mean μ\mu or rate λ\lambda) of the universe, and we used them to predict future data.

Inferential Statistics does the exact opposite. In the real world, the true parameters of the massive, infinite "Population" are forever unknown. We must take a small, random "Sample" of data, and use it to infer, estimate, and guess the true parameters of the population.

1.1 Terminology

  • Population: The entire, complete set of all items of interest. (e.g., All 1.4 billion citizens of India).
  • Parameter: A fixed numerical characteristic of the Population. It is a constant, but usually unknown.
    Examples: Population Mean (μ\mu), Population Variance (σ2\sigma^2), Population Proportion (PP).
  • Sample: A randomly selected subset drawn from the population. (e.g., 5,000 citizens surveyed).
  • Statistic: A numerical characteristic calculated directly from the Sample data. It is a random variable because a different sample will yield a different statistic.
    Examples: Sample Mean (xˉ\bar{x}), Sample Variance (s2s^2), Sample Proportion (p^\hat{p}).

Next — The Central Limit Theorem

1 of 11

Page 2

Wink Notes

B.Tech CSE — 4th Semester

Probability and Statistics

Unit - 4

2. The Central Limit Theorem (CLT)

The CLT is the most profound and magical theorem in all of statistics. It is the sole reason why the Normal Bell Curve is so important.

2.1 The Phenomenon

Suppose the original population follows a bizarre, heavily skewed, completely non-normal distribution. You draw a sample of size nn, and calculate the Sample Mean (xˉ\bar{x}). You do this thousands of times, collecting thousands of xˉ\bar{x} values.

Theorem: Regardless of the shape of the original underlying population distribution, as the sample size nn gets larger, the distribution of the Sample Means will mathematically converge to a perfect Normal Distribution.

2.2 The Parameters of the New Distribution

If the population has mean μ\mu and variance σ2\sigma^2, the distribution of Sample Means will be Normal with:

  • Mean of Sample Means: Exactly equal to the population mean μ\mu.
  • Variance of Sample Means: Shrinks to σ2/n\sigma^2 / n.
  • Standard Error (SE): The standard deviation of the sample means is σ/n\sigma / \sqrt{n}.

Rule of Thumb: The CLT activates and the normal approximation is considered highly accurate when the sample size n30n \ge 30.

Next — Estimation

2 of 11

Page 3

Wink Notes

B.Tech CSE — 4th Semester

Probability and Statistics

Unit - 4

3. Estimation Theory

Because the true population parameter μ\mu is unknown, we must use our sample statistic xˉ\bar{x} as an "Estimator".

3.1 Point Estimation

Providing a single, specific number as the best guess for the parameter.
Example: We sample 50 CPUs, find the average lifespan is 4.2 years, and bluntly declare the population mean is exactly 4.2.

Point estimation is inherently flawed because it gives absolutely zero indication of how confident we are or what the margin of error is.

3.2 Properties of a Good Estimator

How do we know xˉ\bar{x} is a good estimator for μ\mu?

  • Unbiasedness: An estimator is unbiased if its expected value exactly equals the true parameter. Mathematically: E[xˉ]=μE[\bar{x}] = \mu. It doesn't systematically over-guess or under-guess.
  • Consistency: As the sample size nn approaches infinity, the estimator converges exactly to the true parameter. Bigger samples always yield closer guesses.
  • Efficiency: Among all unbiased estimators, the one with the smallest variance is the most efficient. It is the "tightest" guess.

Next — Confidence Intervals

3 of 11

Page 4

Wink Notes

B.Tech CSE — 4th Semester

Probability and Statistics

Unit - 4

4. Confidence Intervals

To fix the flaw of Point Estimation, we use Interval Estimation. Instead of giving one single number, we provide a range of values and attach a probability (confidence level) that the true parameter actually lies within that range.

4.1 The Margin of Error

A Confidence Interval is formatted as:
Point Estimate ±\pm Margin of Error

The Margin of Error depends on three factors:
1. The Standard Error of the statistic (how noisy the data is).
2. The Sample Size
nn (bigger nn shrinks the interval, making it more precise).
3. The Confidence Level (e.g., 95% or 99%). Requiring higher confidence forces the interval to become wider.

4.2 Confidence Interval for Mean (Large Sample, n30n \ge 30)

Because n30n \ge 30, the CLT guarantees normality. We use the Standard Normal ZZ distribution.

Interval: xˉ±Zα/2(σn)\bar{x} \pm Z_{\alpha/2} \left( \frac{\sigma}{\sqrt{n}} \right)

Where Zα/2Z_{\alpha/2} is the critical Z-score from the table. For a standard 95% confidence interval, Z0.025=1.96Z_{0.025} = 1.96.

Next — Introduction to Hypothesis Testing

4 of 11

Page 5

Wink Notes

B.Tech CSE — 4th Semester

Probability and Statistics

Unit - 4

5. Introduction to Hypothesis Testing

In machine learning and A/B testing, you must mathematically prove that a new algorithm or feature actually improves performance, rather than just producing better results by sheer random luck.

Hypothesis testing is a strict judicial procedure for evaluating claims about population parameters using sample evidence.

5.1 The Two Hypotheses

We set up two mutually exclusive, mathematically opposing claims:

  • Null Hypothesis (H0H_0): The assumption of the status quo, no change, no difference, or no effect. It is the "innocent until proven guilty" baseline. It ALWAYS contains an equality sign (=,,=, \le, \ge).
    Example: H0:μ=50H_0: \mu = 50 (The new algorithm takes exactly the same 50ms as the old one).
  • Alternate Hypothesis (H1H_1 or HaH_a): The claim you are trying to mathematically prove. It represents change, difference, or effect. It never contains equality (,<,>\neq, <, >).
    Example: H1:μ<50H_1: \mu < 50 (The new algorithm is strictly faster).

Next — Errors in Hypothesis Testing

5 of 11

Page 6

Wink Notes

B.Tech CSE — 4th Semester

Probability and Statistics

Unit - 4

6. Errors in Hypothesis Testing

Because we are judging the entire massive population based on a tiny sample, our conclusion can sometimes be wrong due to extreme statistical bad luck.

6.1 Type I and Type II Errors

  • Type I Error (False Positive): We Reject the Null Hypothesis when it was actually True.
    Analogy: Sending an innocent person to jail.
    Probability: The probability of committing a Type I error is denoted by α\alpha (Alpha), also known as the Level of Significance. Usually set by the engineer at 0.05 (5%).
  • Type II Error (False Negative): We Fail to Reject the Null Hypothesis when it was actually False.
    Analogy: Letting a guilty criminal walk free.
    Probability: Denoted by β\beta (Beta).

There is an inherent trade-off. If you demand massive evidence to avoid Type I errors (low α\alpha), you automatically increase your risk of committing Type II errors.

Power of the Test: Calculated as 1β1 - \beta. This is the probability that the test correctly detects a real effect and rejects a false Null Hypothesis.

Next — The Rejection Region (Critical Value Method)

6 of 11

Page 7

Wink Notes

B.Tech CSE — 4th Semester

Probability and Statistics

Unit - 4

7. The Rejection Region Method

How much evidence is enough to convict the Null Hypothesis? We define a specific line in the sand based on our chosen α\alpha (e.g., 5%).

7.1 One-Tailed vs Two-Tailed Tests

The Alternate Hypothesis H1H_1 dictates the shape of the rejection region on the bell curve.

  • Two-Tailed Test (H1:μ50H_1: \mu \neq 50): You are looking for any difference, higher or lower. The 5% error risk is split in half (2.5% in the extreme left tail, 2.5% in the extreme right tail).
  • Right-Tailed Test (H1:μ>50H_1: \mu > 50): You only care if the value is higher. The entire 5% error risk is concentrated entirely in the right tail.
  • Left-Tailed Test (H1:μ<50H_1: \mu < 50): The entire 5% error region is in the left tail.

7.2 The Procedure

1. Find the Critical Value (from the Z-table or t-table) that marks the boundary of the rejection region based on α\alpha.
2. Calculate the Test Statistic from your sample data.
3. If your Test Statistic physically falls into the Rejection Region (beyond the critical value), you Reject
H0H_0. If it doesn't, you Fail to Reject H0H_0.

Next — The P-Value Method

7 of 11

Page 8

Wink Notes

B.Tech CSE — 4th Semester

Probability and Statistics

Unit - 4

8. The P-Value Method

Modern software (like Python SciPy or R) does not use Rejection Regions. It outputs a universal metric called the P-value.

8.1 The Definition

The P-value is the probability of obtaining sample data as extreme as (or more extreme than) your current sample, assuming that the Null Hypothesis is completely, 100% True.

If the P-value is extremely small (e.g., 0.01 or 1%), it means your sample data would be a bizarre, astronomically rare coincidence if the Null Hypothesis were true. Therefore, the Null Hypothesis is probably garbage.

8.2 The Golden Rule of Decision Making

You compare the calculated P-value directly against your pre-defined α\alpha (Level of Significance, usually 0.05).

  • If P-value α\le \alpha: The evidence is overwhelmingly strong. Reject H0H_0. The results are statistically significant.
  • If P-value >α> \alpha: The evidence is weak. Fail to Reject H0H_0. The results are not statistically significant (they could just be random noise).

Next — The Z-Test

8 of 11

Page 9

Wink Notes

B.Tech CSE — 4th Semester

Probability and Statistics

Unit - 4

9. The Z-Test (Large Samples)

The Z-test is used to test claims about the population mean μ\mu.

9.1 When to use the Z-Test

You can ONLY use the Z-test if the Central Limit Theorem is active, guaranteeing a Normal Distribution. This requires:

  • The sample size is large (n30n \ge 30).
  • OR the sample is small, but you miraculously know the exact true variance σ2\sigma^2 of the entire massive population (extremely rare in reality).

9.2 The Test Statistic Formula

You must convert your sample mean xˉ\bar{x} into a Standard Normal Z-score. We use the Standard Error σ/n\sigma / \sqrt{n} in the denominator.

Zcalc=xˉμ0σ/nZ_{calc} = \frac{\bar{x} - \mu_0}{\sigma / \sqrt{n}}

Where:
-
xˉ\bar{x}: The average calculated from your small sample.
-
μ0\mu_0: The baseline population mean claimed in the Null Hypothesis.
-
σ\sigma: Population standard deviation (if unknown, substitute with sample standard deviation ss since n30n \ge 30).
-
nn: Sample size.

Next — The Student's t-Test

9 of 11

Page 10

Wink Notes

B.Tech CSE — 4th Semester

Probability and Statistics

Unit - 4

10. The Student's t-Test (Small Samples)

What if testing 30 prototypes is too expensive? What if you can only afford to test n=10n = 10 items?

When n<30n < 30, the Central Limit Theorem collapses. You cannot use the Z-table because the distribution is no longer perfectly Normal. It becomes "fatter" in the tails to account for the extreme uncertainty of having so little data.

We must use the Student's t-distribution, discovered by William Sealy Gosset (who published under the pen name "Student").

10.1 Degrees of Freedom (df)

There is no single t-distribution. There is an infinite family of t-curves, one for every sample size. You identify the correct curve using Degrees of Freedom.

df=n1df = n - 1

10.2 The Test Statistic

The formula is algebraically identical to the Z-test, but you strictly use the sample standard deviation ss, and you MUST look up the critical value in the t-table using your dfdf, NOT the Z-table.

tcalc=xˉμ0s/nt_{calc} = \frac{\bar{x} - \mu_0}{s / \sqrt{n}}

Next — Summary Checklist

10 of 11

Page 11

Wink Notes

B.Tech CSE — 4th Semester

Probability and Statistics

Unit - 4

11. Summary Checklist

Unit 4 is the core of practical statistics. Every single experiment in modern science and A/B testing relies entirely on these concepts.

11.1 University Exam Checklist

  • Define Population, Parameter, Sample, and Statistic.
  • Explain the Central Limit Theorem (CLT) and why the sample size n=30n=30 is critical.
  • List the three mathematical properties of a good Point Estimator (Unbiased, Consistent, Efficient).
  • Calculate a 95% Confidence Interval for the population mean given a large sample. Explain what the interval physically represents.
  • Define the Null Hypothesis (H0H_0) and Alternate Hypothesis (H1H_1).
  • Explain the exact difference between a Type I error (False Positive) and a Type II error (False Negative). What is α\alpha?
  • Explain the concept of a p-value. If p=0.02p = 0.02 and α=0.05\alpha = 0.05, do you reject the null hypothesis?
  • Execute a full 5-step Hypothesis Test using the Z-test formula for a large sample. Formulate hypotheses, calculate ZcalcZ_{calc}, compare to ZcriticalZ_{critical}, and state the conclusion.
  • Execute a Hypothesis Test using the Student's t-test for a small sample (n<30n < 30). Calculate Degrees of Freedom.

11 of 11

Continue in this subject