Does the p-value I got with the 1 Sample T-Test make sense, knowing the mean of `ages`?

Hello, everyone.

I can’t find the answer to question number four on this exercise

The Null Hypothesis is

Are the visitors too old? Or is this just the result of chance and a small sample size?

For this code

from scipy.stats import ttest_1samp
import numpy as np

ages = np.genfromtxt("ages.csv")

ages_mean = np.mean(ages)

tstat, pval = ttest_1samp(ages, 30)

I get these numbers

[ 32.  34.  29.  29.  22.  39.  38.  37.  38.  36.  30.  26.  22.  22.] #ages list
31.0 #true mean
0.560515588817 #pvalue

And the question asked is

Does the p-value you got with the 1 Sample T-Test make sense, knowing the mean of ages ?

The p-value says there is a 56% chance that my null hypothesis is true and the result is due to chance.
So an expected mean of 30 has 56% of chance that my null hypothesis is true, but the true mean is 31, this is pretty close to 30, i think that this result for p-value makes no sense at all. Given the true mean, it should be a much lower p-value for such a close expected mean.

Am i right in my thinking and my answer? I’m confused and have no confidence that this is a right train of thought.

Thank you for your time

The question is whether or not you can reject the null hypothesis. If you can, you can say there is a lack of evidence that “The set of samples belongs to a population with the target mean”.

1 Like


I just finished answering (in depth) your other question regarding 1 Sample T-tests. Check that out and see if it clears things up for this question as well.

1 Like