import json
import math
import numpy as np
from scipy import stats
import matplotlib.pyplot as plt
data_list = []
with open('test_130380_73.log','r') as f:
data = f.readlines()
#readlines按行讀取返回?cái)?shù)組,遍歷數(shù)組元素
for i in data:
item = i.split('<<<<<')
each = item[1].split('>')
data_list.append(json.loads(each[0]) )
cache = []
mysql = []
emqt = []
push = []
all = []
for dic in data_list:
if dic['type'] == 'mysql':
mysql.append(dic['use'])
elif dic['type'] == 'cache':
cache.append(dic['use'])
elif dic['type'] == 'emqt':
emqt.append(dic['use'])
elif dic['type'] == 'push':
push.append(dic['use'])
elif dic['type'] == 'all':
all.append(dic['use'])
# print('cache用時(shí):',cache)
# print('mysql時(shí)間:',mysql)
# print('emqt時(shí)間:',emqt)
# print('push時(shí)間:',push)
# print('all時(shí)間:',all)
#stats.t.interval(置信度,自由度,均值,標(biāo)準(zhǔn)差) 得到置信區(qū)間
mysql_ci = stats.t.interval(0.95, df=len(mysql)-1, loc=np.mean(mysql), scale=stats.sem(mysql))
cache_ci = stats.t.interval(0.95, df=len(cache)-1, loc=np.mean(cache), scale=stats.sem(cache))
emqt_ci = stats.t.interval(0.95, df=len(emqt)-1, loc=np.mean(emqt), scale=stats.sem(emqt))
push_ci = stats.t.interval(0.95, df=len(push)-1, loc=np.mean(push), scale=stats.sem(push))
all_ci = stats.t.interval(0.95, df=len(all)-1, loc=np.mean(all), scale=stats.sem(all))
print('mysql_ci',mysql_ci)
print('cache_ci',cache_ci)
print('emqt_ci',emqt_ci)
print('push_ci',push_ci)
print('all_ci',all_ci)
print('cache樣本數(shù):',len(cache),'最大用時(shí):',max(cache),'最小用時(shí):',min(cache),'cache均值:','%.2f' % np.mean(cache))
print('emqt樣本數(shù)',len(emqt),'最大用時(shí):',max(emqt),'最小用時(shí):',min(emqt),'emqt均值:','%.2f' % np.mean(emqt))
print('push樣本數(shù)',len(push),'最大用時(shí):',max(push),'最小用時(shí):',min(push),'push均值:','%.2f' % np.mean(push))
print('all樣本數(shù)',len(all),'最大用時(shí):',max(all),'最小用時(shí):',min(all),'all均值:','%.2f' % np.mean(all))
print('mysql樣本數(shù)',len(mysql),'最大用時(shí):',max(mysql),'最小用時(shí):',min(mysql),'mysql均值:','%.2f' % np.mean(mysql))
scipy之t分布獲取均值置信區(qū)間
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
相關(guān)閱讀更多精彩內(nèi)容
- 樣本均值、比例等于總體均值、比例的點(diǎn)估計(jì)量,這是無偏樣本最可能的情況。但是這一情況仍有可能是錯(cuò)誤的,因?yàn)楫吘故且粋€(gè)...
- 準(zhǔn)備數(shù)據(jù)data,存成int型list,或float型list導(dǎo)入模塊 正態(tài)分布檢驗(yàn)的兩種方法 繪制直方圖+正態(tài)分...
- 一、誤差思維一個(gè)量在測量、計(jì)算或觀察過程中由于某些錯(cuò)誤或通常由于某些不可控制的因素的影響而造成的變化偏離標(biāo)準(zhǔn)值或規(guī)...
- 機(jī)器學(xué)習(xí)的本質(zhì)就是對(duì)條件概率或概率分布的估計(jì),一直以來,對(duì)這個(gè)知識(shí)點(diǎn)總是似懂非懂,偶然間看到這篇文章,學(xué)習(xí)+實(shí)踐記...