One-Sample T-tests

tags: #statistics/inferential/ttest/one_sample

What is a one-sample t-test?

The One Sample T-test examines whether the mean of a population is statistically different from a known or hypothesized value.
 
To compare the means of multiple groups to each other, use either:

This follows the sample assumptions and conditions as a two-sample (independent) t-test.

Hypothesis Model

The hypothesis model for a one-sample t-test for comparing the sample mean to a known or hypothesized value is:

H0:μ=μ0, where the population mean is equal to the [proposed] population meanHA:μμ0, where the population mean does NOT equal to the [proposed] population mean
Calculating the test statistic

For calculating the test statistic:

t=y¯μ0SE(y¯), where SE(y¯)=sn

Running a one-sample t-test in Python

We can conduct a one-sample t-test in Python using the ttest_1samp() function  from the scipy.stats library:

from scipy.stats import ttest_1samp

# conduct one-sample t-test
ttest_1samp(a, popmean, alternative="two-sided", alpha=0.05)

Parameters:

This returns the following:

(statistics, p-value)
Powered by Forestry.md