Data AnalyticsStatistics for analytical decisions

Choose a t-test from the question and data design

PK
Pankit Kumar
Sr. Data Scientist at Parexel (a Goldman Sachs–backed company) · 20 September 2026 · 3 min read
Technically reviewed by Ishaan Sharma
In this article (6 sections)

Choose the t procedure from the comparison and the dependence structure. A one-sample test compares a mean with a specified reference. A paired test analyzes within-pair differences. An independent-sample test compares separate groups.

Do not select whichever procedure returns the smallest p-value. The correct unit and design must be established before the result is inspected.

Map the question to the structure

QuestionData structureCandidate procedure
Does a mean differ from a fixed benchmark?One independent sampleOne-sample t test
Did the same people change?Matched before/after measurementsPaired t test on differences
Do separate groups have different means?Independent units in each groupIndependent-sample t procedure

These are candidate methods, not automatic approvals. Distribution shape, outliers, sample size, clustering and the target estimand still need review.

Execute an independent-group example

The analyst statistics lab supplies two separate groups of eight synthetic scores. Control mean is 41.5 and treatment mean is 48.0. For this exercise, assume independent units and use Welch's procedure without assuming equal population variances.

python
import numpy as np
from scipy import stats
from build_and_verify import CONTROL, TREATMENT

result = stats.ttest_ind(TREATMENT, CONTROL, equal_var=False,
                         alternative='two-sided', nan_policy='raise')
difference = float(TREATMENT.mean() - CONTROL.mean())
se = np.sqrt(TREATMENT.var(ddof=1)/len(TREATMENT) + CONTROL.var(ddof=1)/len(CONTROL))
assert difference == 6.5
assert np.isclose(result.statistic, difference/se)
assert np.isclose(result.statistic, 5.507570547286102)
interval = result.confidence_interval(confidence_level=.95)
assert interval.low < difference < interval.high
print({'difference': difference, 't': float(result.statistic), 'df': float(result.df),
       'p': float(result.pvalue), 'ci95': [float(interval.low), float(interval.high)]})

The recorded two-sided p-value is approximately 0.0000788. This is a numerical result under the exercise's model, not a probability that the treatment is effective or a measured NeuraPath learning outcome.

The SciPy ttest_ind reference documents the Welch option and returned interval. NIST's two-sample t-test guide describes the comparison and variance assumptions.

Keep pairing tied to identity

Two arrays of the same length are not automatically paired. Pairing requires a meaningful relationship, such as measurements on the same person or an explicitly matched design.

Conversely, treating repeated measurements on the same people as independent ignores their dependence. Join measurements by stable identity and validate one-to-one pairing before calculating differences.

Inspect assumptions rather than outsourcing them to a pretest

Review the sampling design, distribution and unusual values. A nonsignificant normality test on a tiny sample does not prove normality. A variance pretest should not become an automatic switch that replaces reasoning about the independent-group comparison.

If the outcome is a conversion indicator, heavily dependent time series or clustered customer behavior, consider methods designed for that structure. A familiar function name is not sufficient justification.

Report magnitude and uncertainty

The estimated difference is 6.5 score units. Its practical meaning depends on the score scale and a prespecified meaningful effect. A small p-value alone does not answer whether the difference matters operationally.

Also distinguish association from causation. The labels control and treatment in a CSV do not prove random assignment. A causal interpretation requires an appropriate design and its assumptions.

Exercise: analyze the lab's paired_scores.csv using its person identifiers. Explain why the paired method is justified there and why merely renaming the columns group_A and group_B would not make the observations independent.

NeuraPath's Data Analytics with Generative AI course connects hypothesis testing with data design. A defensible test starts with the question and the unit of evidence, then reports the effect in useful units.

Continue learning

This article is part of the Statistics for analytical decisions sequence. Use the neighbouring tasks when you need the prerequisite or the next application.

PK
Pankit Kumar
Lead Instructor, NeuraPath Academy

Pankit Kumar has 10 years in Data Science & AI, building and shipping production systems in regulated pharma and clinical environments. He is a freelance trainer at Boston Institute of Analytics, AnalytixLabs and Scaler, and has taught this material to thousands of working professionals.

This article is part of our Data Analytics with Generative AI programme — 3–4 months. The full analyst stack — Excel, SQL, Power BI and Python pipelines — then a generative-AI layer you can prove is right.

Explore Data Analytics with Generative AI
Counselling is free · no obligation

Not sure which programme fits?

Tell us your background and we will map it to the right entry point — including saying so when a cheaper programme is the better fit. A counsellor replies within one working day.