Inferential Statistics

Suyog TimalsinaSuyog Timalsina
2 min read

Introduction

Inferential statistics is a branch of statistics that allows us to make conclusions about a larger population based on a sample of data. Unlike descriptive statistics, which only summarizes data, inferential statistics helps us make decisions, predictions, or generalizations beyond the data we have.

In this post, we will explore key concepts such as confidence intervals, hypothesis testing, p-values, and the difference between parametric and non-parametric tests. I’ll also share how I learned these concepts using my iPad notes and show some simple Python examples to practice.

Confidence Intervals (CI)

A confidence interval gives us a range of values within which we believe the true population parameter (like a mean) lies, with a certain level of confidence (usually 95%).

Python example — calculating a 95% confidence interval for a sample mean:

import numpy as np
import scipy.stats as stats

data = [12, 15, 14, 16, 13, 15, 17, 16]

mean = np.mean(data)
sem = stats.sem(data)

ci = stats.t.interval(0.95, len(data)-1, loc=mean, scale=sem)
print(f"95% confidence interval: {ci}")
# 95% confidence interval: (13.214553720513117, 16.785446279486884)

Hypothesis Testing

Hypothesis testing is a method to test an assumption (hypothesis) about a population parameter.

import numpy as np
from scipy import stats

# Sample data (weights in kg)
data = [52, 49, 51, 48, 50, 53, 47, 49, 52, 50]

# Hypothesized population mean
mu = 50

# Perform one-sample t-test
t_stat, p_value = stats.ttest_1samp(data, popmean=mu)

print(f"T-statistic: {t_stat:.3f}")
print(f"P-value: {p_value:.3f}")

# Significance level
alpha = 0.05

if p_value < alpha:
    print("Reject null hypothesis: The average weight is significantly different from 50 kg.")
else:
    print("Fail to reject null hypothesis: Not enough evidence to say the average weight differs from 50 kg.")

Understanding P-value

The p-value tells us how surprising our sample data is if the null hypothesis were true.

✅ Think of it like this:

It’s the probability of getting data as extreme (or more extreme) as what we observed, assuming the null hypothesis is true.

What’s Next: Exploring Parametric Tests

Now that we’ve covered the fundamentals of inferential statistics—like confidence intervals, hypothesis testing, and p-values—you’re equipped with the basics to start making data-driven decisions. But how do we choose which statistical tests to use on different kinds of data? That’s where parametric tests come in.

In the next blog, I’ll explain what parametric tests are, the assumptions behind them, and how you can apply these tests to real-life datasets. Understanding parametric methods will help you analyze data more effectively and confidently. Stay tuned!

0
Subscribe to my newsletter

Read articles from Suyog Timalsina directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Suyog Timalsina
Suyog Timalsina