How to do a two-sided hypothesis test for a sample mean (in Julia)
Task
Say we have a population whose mean
Related tasks:
- How to compute a confidence interval for a population mean
- How to do a two-sided hypothesis test for two sample means
- How to do a one-sided hypothesis test for two sample means
- How to do a hypothesis test for a mean difference (matched pairs)
- How to do a hypothesis test for a population proportion
Solution
This is a two-sided test with the null hypothesis
1
2
3
4
5
6
7
8
9
10
# Replace these first three lines with the values from your situation.
alpha = 0.05
pop_mean = 10
sample = [ 9, 12, 14, 8, 13 ]
# The following code runs the test for your chosen alpha:
using HypothesisTests
p_value = pvalue( OneSampleTTest( sample, pop_mean ) )
reject_H0 = p_value < alpha
alpha, p_value, reject_H0
(0.05, 0.35845634462296455, false)
In this case, the
When you are using the most common value for
1
OneSampleTTest( sample, pop_mean )
One sample t-test
-----------------
Population details:
parameter of interest: Mean
value under h_0: 10
point estimate: 11.2
95% confidence interval: (7.986, 14.41)
Test summary:
outcome with 95% confidence: fail to reject h_0
two-sided p-value: 0.3585
Details:
number of observations: 5
t-statistic: 1.0366421106976316
degrees of freedom: 4
empirical standard error: 1.1575836902790224
Content last modified on 24 July 2023.
See a problem? Tell us or edit the source.
Contributed by Nathan Carter (ncarter@bentley.edu)