user3476463
user3476463

Reputation: 4575

hypothesis test population and sample averages

I have a population that has an average weight of 5 lbs. I've taken sample of 5879 observations from the population. The sample has a total weight of 410522 lbs. I'm trying to figure out if the sample has a significantly higher average weight than the population. Assuming that the population has a normal distribution. I'm trying to use the proportions_ztest from stats model. I'm not sure if I'm using the counts and nobs variables correctly. Can someone please tell me if I'm using the function correctly, or suggest another function? I'm trying to get the p-value.

code:

import statsmodels.api as sm

cnt=410522
nbs=58759
vL=5


sm.stats.proportions_ztest(cnt, 
                                  nbs,
                                  vL, 
                                  alternative='larger')[1]

Upvotes: 0

Views: 314

Answers (1)

Ha Bom
Ha Bom

Reputation: 2917

You can use scipy.stats.ttest_1samp(a, popmean) to get t and p_value.

This is a two-sided test for the null hypothesis that the expected value (mean) of a sample of independent observations a is equal to the given population mean, popmean.

Read more detail here.

If you want to test if the samples has a significantly higher average weight than the population, you should divide the P-value/2 to get right-tailed P_value.

Upvotes: 1

Related Questions