資源簡(jiǎn)介
1.某菜店元月份逐日銷售額(元)資料如下:
257 276 297 252 228 310 240 228265 278 271 292 261 281 301 274
267 280 291 258 272 284 268 303
273 282 263 322 249 269 290
要求:
(1)計(jì)算該菜店元月份每日平均銷售收入和標(biāo)準(zhǔn)差以及銷售收入的中位數(shù);
(2)試以10元為組距對(duì)該資料進(jìn)行分組,分為10組,并畫出直方圖;
(3)利用分組數(shù)據(jù)近似計(jì)算該數(shù)據(jù)的均值、中位數(shù)和眾數(shù);
(4)若去掉兩個(gè)最高收入額、去掉兩個(gè)最低收入額,用切尾均值公式計(jì)算其均值;
(5)以10元為組距分為11組,將該數(shù)據(jù)用莖葉圖表示出來;
(6)計(jì)算上述資料的兩個(gè)四分位數(shù)。
代碼片段和文件信息
print(‘1.1答案:‘)
import?numpy?as?np
import?matplotlib.pyplot?as?plt
arr=[257276297252228310240228265278271292261281301274267280291258272284268303273282263322249269290]
arr_mean=np.mean(arr)#求平均值
arr_std=np.std(arrddof=1)#求標(biāo)準(zhǔn)差
L?=?sorted(arr)#求中位數(shù)
print(‘平均值=‘a(chǎn)rr_mean)
print(“標(biāo)準(zhǔn)差=“arr_std)
print(“中位數(shù)=“L[len(L)//2]?if?len(L)%2==1?else?“%.1f“%(0.5*(L[len(L)//2-1]+L[len(L)//2])))
print(‘1.2答案:‘)
plt.rcParams[‘font.sans-serif‘]=[‘SimHei‘]
plt.rcParams[‘a(chǎn)xes.unicode_minus‘]?=?False
import?numpy?as?np
Lenths?=[257276297252228310240228265278271292261281301274267280291258272284268303273282263322249269290]
plt.hist(arr10)
plt.xlabel(‘銷售額‘)
plt.ylabel(‘次數(shù)‘)
plt.title(‘直方圖‘)
plt.show()
print(‘1.3答案:‘)
import?numpy?as?np
import?matplotlib.pyplot?as?plt
arr1=[225225235245245255255255255255265265265265265265265275275
評(píng)論
共有 條評(píng)論