统计学(第7版)-7.1 python解答
程序员文章站
2022-11-21 18:15:21
import numpy as npimport pandas as pdfrom pandas import read_excelimport statsmodels.api as smfrom scipy import stats food = pd.read_excel('D:\\百度网盘\\ ......
import numpy as np
import pandas as pd
from pandas import read_excel
import statsmodels.api as sm
from scipy import stats
import pandas as pd
from pandas import read_excel
import statsmodels.api as sm
from scipy import stats
food = pd.read_excel('d:\\百度网盘\\统计学(第6版)贾俊平\\data\\7-1.xlsx')
#使用statsmodels提供的类descrstatsw配合其zconfint_mean方法可得到正态估计区间
z_minmax = sm.stats.descrstatsw(food).zconfint_mean(alpha=0.05)
#(array([101.16400895]), array([108.96099105]))
#(array([101.16400895]), array([108.96099105]))
#t分布下的估计
t_minmax = sm.stats.descrstatsw(food).tconfint_mean(alpha=0.05)
#(array([100.94781052]), array([109.17718948]))
t_minmax = sm.stats.descrstatsw(food).tconfint_mean(alpha=0.05)
#(array([100.94781052]), array([109.17718948]))
#stats.bayes_mvs也提供了采用t分布下的均值估计结果
m_mean,m_var,m_std = stats.bayes_mvs(food, alpha=0.95)
#mean(statistic=105.0625,
# minmax=(100.94781051938365, 109.17718948061635))
m_mean,m_var,m_std = stats.bayes_mvs(food, alpha=0.95)
#mean(statistic=105.0625,
# minmax=(100.94781051938365, 109.17718948061635))
--------------------------------------
附数据如下:一家食品生产企业以生产袋装食品为主,为对产量质量进行监测,企业质检部门经常要进行抽检,以分析每袋重量是否符合要求.现从某天生产的一批食品中随机抽取了25袋,测得每袋重量如下表所示.已知产品重量的分布服从正态分布,且总体标准差为10g.试估计该批产品平均重量的置信区间,置信水平为95%。
112.50 101.00 103.00 102.00 100.50
102.60 107.50 95.00 108.8 115.60
100.00 123.50 102.00 101.60 102.20
116.60 95.40 97.8 108.60 105.00
136.80 102.80 101.50 98.40 93.30
102.60 107.50 95.00 108.8 115.60
100.00 123.50 102.00 101.60 102.20
116.60 95.40 97.8 108.60 105.00
136.80 102.80 101.50 98.40 93.30
上一篇: 我只是说实话
下一篇: Yii框架应用组件用法实例分析