harmonic mean-调和平均数

 调和平均数的公式[1]:
H = n 1 x 1 + 1 x 2 + 1 x 3 + . . . + 1 x n H=\frac{n}{\frac{1}{x_1}+\frac{1}{x_2}+\frac{1}{x_3}+...+\frac{1}{x_n}} H=x11+x21+x31+...+xn1n
 定义很简单,具体有什么应用价值呢,网上的博客没有说。[2]是研究dash视频传输的,就是怎么根据预测的带宽,去请求合适的码率。而根据历史数据预测带宽,harmonic mean就有了用武之地。文中说这个方法能够有效滤除异常值。

First, the harmonic mean is more appropriate when we want to compute the average of rates which is the case with throughput estimation. Second, it is also more robust to larger outliers.

 python实现:

import os
class HarmnicMean(object):
    def __init__(self,window):
        self.w=window
        self.c=0
        self.his=[]
    def newSample(self,s):
        mean=0.0
        sample=float(s)
        if self.c==0:
            mean=sample
        if sample>0:
            self.his.append(1000/sample)
            self.c+=1
        if self.c>self.w:
            a=self.his[self.c-self.w:]
            self.his=a
            if len(self.his)!=self.w:
                print "error"
            self.c=self.w
        if self.c<self.w:
            mean=self.c*1000/sum(self.his)
        if self.c==self.w:
            mean=self.w*1000/sum(self.his)
        return mean
h=HarmnicMean(20)
fileName="data_in.txt"
f_h=open("data_out.txt",'w')
with open(fileName) as txtData:
    for line in txtData.readlines():
        lineArr = line.strip().split()
        x=lineArr[0]
        y=float(lineArr[2])
        mean=h.newSample(y)
        f_h.write(x+"\t"+str(mean)+"\n")
f_h.close()        

 看看处理效果如何:
在这里插入图片描述
在这里插入图片描述
[1] Harmonic mean
[2] Improving Fairness, Efficiency, and Stability in HTTP-based Adaptive Video Streaming with FESTIVE

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
adumbrate预示(ad+umbr影子+ate→[将来的]影子出现→预示) adjust调整(ad+just+正确→弄正确→调整) adventure冒险(ad+venture冒险) admonish告诫,警告(ad+mon警告+ish→一再警告) advent来临,来到(ad+vent来→来到) 5、amphi-表示"两个,两种" amphibian两栖动物(amphi+bi生命+an→两个生命→两栖动物) amphicar水陆两用车(amphi+car车→两用车) 6、an-在词根前,表示"不,无" anarchism无政府主义(an+arch统治+ism→无统治→无政府主义) anharmonic不和谐的(an+hamonic和谐的→不和谐的) anechoic无回声的(an+echo回声+ic→无回声的) anonymous匿名的(an+onym名字+ous→匿名的) 7、ana-表示"错误,在旁边,分开" analogy类比;类似(ana+logy讲话→再旁边讲→讲一样的东西→类似) analogous类似的(analogy的形容词) analysis分析(ana+lysis分开→分开来→分析) 8、ante-表示"前面,先" antedate提前写日期;先于,早于(ante+date日期→提前写日期) anterior前面的(ante+erior[…的] →前面的) antecedent(aute+ced走+ent→走在前面的[事] →前事) 9、anti-表示"反对,相反" antiwar反战的(anti+war战争) antipathy反感(anti+pathy感情) antithesis对立;反论(anti+thesis论文;观点) antibacterial 抗菌的(anti+bacterial细菌的) antibody抗体(anti+body身体) 10、-anthrop(o)人,人类 anthropology[anthropo人类,-logy…学者]人类学 anthropologist[anthropo人类,-logist…学者]人类学者 anthropogeography[anthropo人类,gegoraphy地理学]人类地理学 anthropomorphous[anthropo人,morph形,-ous…的]有人形的,似人的 anthroposociology [anthropo人类,sociology社会学]人类社会学 11、popul人民―(1) population[popul人民→居民,-ation名词字尾]全体居民,人口 populous [popul人民→居民,-ous…的]人口稠密的 populate [popul人民,-ate动词字尾,使…,做…]使人民居住于…中,使人口集中在…之中,移民于…. Repopulate [re-再,重新,见上]使人民重新居住于… Depopulate [de-除去,去掉,popul人民→人口,-ate使…]使(某地)人口减少,减少人口 Popularity[见上,-ity名词字尾,表示性质]大众性,通俗性 Popularize[见上,- ize…化,使…](使)大众化,(使)普及,推广 Popularizer[见上,-er者]普及者,推广者

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值