🎉 75% of content is free forever — Unlock Premium from $10/mo →
CW
Search courses…
💼 Servicesℹ️ About✉️ ContactView Pricing Plansfrom $10

One-Sample T-Test — Complete Guide with Python

Hypothesis TestingParametric Tests🟢 Free Lesson

Advertisement

One-Sample T-Test

Hypothesis Testing

The Everyday Workhorse for Mean Comparisons

The one-sample t-test is the most commonly used hypothesis test, applicable whenever σ is unknown — which is nearly always in practice. It provides reliable inference even with small samples.

  • Quality Assurance — Testing whether product dimensions meet specifications
  • Education Research — Comparing class performance against national averages
  • Healthcare — Evaluating whether patient measurements differ from healthy norms

When σ is unknown, the t-test is always the right choice.


The one-sample t-test tests whether a population mean μ equals a hypothesized value μ₀, when σ is unknown (the typical real-world case).

The t-distribution has heavier tails than the normal, accounting for uncertainty in estimating σ with s.


Assumptions


Checking Normality


Complete Worked Example


T-Distribution: Degrees of Freedom Effect

x = np.linspace(-5, 5, 500)
fig, ax = plt.subplots(figsize=(10, 5))

ax.plot(x, stats.norm.pdf(x), 'k-', linewidth=2, label='Normal (df=∞)')
for df in [1, 2, 5, 10, 30]:
    ax.plot(x, stats.t.pdf(x, df=df), linewidth=1.5, label=f't (df={df})')

ax.set_xlim(-5, 5)
ax.set_title('T-Distribution vs Normal: Heavy Tails Decrease with df')
ax.legend()
ax.set_xlabel('t')
ax.set_ylabel('Density')
plt.savefig('t_distribution.png', dpi=150)
plt.show()

Power Analysis


Key Takeaways

Need Expert Statistics Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement