首页 > 其他分享 >第九章

第九章

时间:2025-01-03 20:56:16浏览次数:1  
标签:plt 第九章 print flatten rcParams np model

9.2

import numpy as np
import pandas as pd
import scipy.stats as ss
import statsmodels.api as sm
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif']=['Times New Roman + SimSun + WFM Sans SC']
plt.rcParams['mathtext.fontset']='stix'
plt.rcParams['axes.unicode_minus']=False
plt.rcParams['figure.dpi'] = 200
plt.rcParams['xtick.direction']='in'
plt.rcParams['ytick.direction']='in'
data = np.loadtxt("C:/Users/qazws/OneDrive/python代码/python建模作业/ti9_2.txt").flatten()
mu = data.mean()
sig = data.std(ddof=1)
st, p = ss.kstest(data, 'norm', (mu, sig))
print("统计量:", st)
print("p值:", p)
print(“2022310143024”)

 

9.3

import numpy as np
import pandas as pd
import scipy.stats as ss
import statsmodels.api as sm
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif']=['Times New Roman + SimSun + WFM Sans SC']
plt.rcParams['mathtext.fontset']='stix'
plt.rcParams['axes.unicode_minus']=False
plt.rcParams['figure.dpi'] = 200
plt.rcParams['xtick.direction']='in'
plt.rcParams['ytick.direction']='in'
df = pd.read_excel("C:/Users/qazws/OneDrive/python代码/python建模作业/ti9_3.xlsx", header=None)
fig = plt.figure()
ax = fig.add_subplot(111)
labels = ['Lab'+str(i) for i in range(1, 8)]
ax.boxplot(df, sym='xr', labels=labels)
fig.show()
y = df.values
x = np.tile(np.arange(1, 8), (10, 1))
model_dic = {'x': x.flatten(), 'y': y.flatten()}
model = sm.formula.ols('y~C(x)', model_dic).fit()
anovat = sm.stats.anova_lm(model)
print(anovat)
print(“2022310143024”)

9.4

import numpy as np
import pandas as pd
import scipy.stats as ss
import statsmodels.api as sm
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif']=['Times New Roman + SimSun + WFM Sans SC']
plt.rcParams['mathtext.fontset']='stix'
plt.rcParams['axes.unicode_minus']=False
plt.rcParams['figure.dpi'] = 200
plt.rcParams['xtick.direction']='in'
plt.rcParams['ytick.direction']='in'
data = np.loadtxt("C:/Users/qazws/OneDrive/python代码/python建模作业/ti9_4.txt")
x1 = np.tile(np.arange(1, 4), (12, 1)).T
x2 = np.tile(np.array([1,1,1,2,2,2,3,3,3,4,4,4]), (3, 1))
model_dic = {'x1': x1.flatten(), 'x2': x2.flatten(), 'y': data.flatten()}
model = sm.formula.ols('y~C(x1)*C(x2)', model_dic).fit()
print(sm.stats.anova_lm(model))
print(“2022310143024”)

9.5

import numpy as np
import pandas as pd
import scipy.stats as ss
import statsmodels.api as sm
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif']=['Times New Roman + SimSun + WFM Sans SC']
plt.rcParams['mathtext.fontset']='stix'
plt.rcParams['axes.unicode_minus']=False
plt.rcParams['figure.dpi'] = 200
plt.rcParams['xtick.direction']='in'
plt.rcParams['ytick.direction']='in'
data = np.loadtxt("C:/Users/qazws/OneDrive/python代码/python建模作业/ti9_5.txt")
x1 = np.vstack([np.ones((4, 4)), np.ones((4, 4))*2, np.ones((4, 4))*3])
x2 = np.tile(np.array([[1, 1, 2, 2]]).T, (3, 4))
x3 = np.tile(np.array([[1, 2]]).T, (6, 4))
model_dic = {
'x1': x1.flatten(),
'x2': x2.flatten(),
'x3': x3.flatten(),
'y': data.flatten()
}
model = sm.formula.ols('y~C(x1)+C(x2)+C(x3)', model_dic).fit()
print(sm.stats.anova_lm(model))
print(“2022310143024”)

标签:plt,第九章,print,flatten,rcParams,np,model
From: https://www.cnblogs.com/yinhao3024/p/18650894

相关文章

  • 第九章
    9.3点击查看代码importmatplotlib.pyplotaspltdata=[[4.13,3.86,4.00,3.88,4.02,4.02,4.00],[4.07,3.85,4.02,3.88,3.95,3.86,4.02],[4.04,4.08,4.01,3.91,4.02,3.96,4.03],[4.07,4.11,4.01,3.95,3.89,3.97,4.04],[4......
  • 《程序员修炼之路——从小工到专家》第九章学习笔记
    读《程序员修炼之路:从小工到专家》第九章有感第九章聚焦于程序员如何实现持续成长与创新,读完令人思绪万千。书中着重指出,技术领域瞬息万变,持续学习是程序员的立身之本。如逆水行舟,不进则退,持续关注新技术、新框架,才能在行业浪潮中站稳脚跟,这让我深感自身学习紧迫感。创新思维的......
  • alpha 第九章 集合
    ArrayList<String>list=newArrayList<>();与ArrayList的区别: 同步性:Vector是同步的,支持多线程并发访问。而ArrayList是异步的,因而ArrayList中的对象是线程不安全的 效率:Vector的执行效率比ArrayList差 数据增长:添加新元素时,当数组容量不够时需要扩容时,Vector缺省......
  • 第九章例题及习题
    例9.1fromscipy.statsimportexpon,gammaimportpylabaspltx=plt.linspace(0,3,100)L=[1/3,1,2]s1=['*-','.-','o-']s2=['$\\alpha=1,\\beta=\\frac{1}{3}$','$\\alpha=1,\\beta=1$',&#......
  • 2024/12月 读书笔记 - 9《构建之法》--- 第九章
    在项目管理领域,不同公司对于项目管理角色的称呼有所不同。以下是几种常见的项目管理角色:ProductManager(PM):产品经理,负责确保产品正确地开发和实现。ProjectManager(PM):项目经理,负责确保项目流程正确地执行。ProgramManager:在微软,这个职位指的是负责特定项目或程序的经理......
  • 【软件工程】第九章·系统测试(因果图全解析)
    ......
  • 第九章:变更
    1.变更流程CCB变更控制委员会变更控制委员会(ChangeControlBoard,CCB)一般由项目发起人、客户、PM组成,是一个正式的跨职能团队,在项目管理中负责对项目变更请求进行审查、评估、批准或拒绝。他是项目变更管理体系中的核心决策机构,确保项目变更在合理的范围内进行,并且与项......
  • 第九章
    学号后四位30209.2点击查看代码importnumpyasnpfromscipy.statsimportshapirodata=[15.0,15.8,15.2,15.1,15.9,14.7,14.8,15.5,15.6,15.3,15.1,15.3,15.0,15.6,15.7,14.8,14.5,14.2,14.9,14.9,15.2,15.0,15.3,15.6,15.1,14.9,14.2,14.6......
  • python第九章课后习题
    9.2某车间生产滚珠,随机的抽出了50粒,测得他们的直径为(单位mm)15.015.815.215.115.914.714.815.515.615.315.115.315.015.615.714.814.514.214.914.915.215.015.315.615.114.914.214.615.815.215.915.215.014.914.814.515.115.515.515.115.1......
  • 第九章 DIV+CSS布局
    9.1DIV+CSS概述DIV+CSS是Web设计标准,它是一种网页的布局方法。与传统中通过表格(table)布局定位的方式不同,它可以实现网页页面内容与表现相分离。DIV组成了网页的格局,CSS则装饰了格局,比如建一栋房子,开始的架子是DIV,架子搭建好后开始装饰,这个装饰就是CSS样式。用DIV+CSS布局......