hawkes.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:academic 作者: xinchrome 项目源码 文件源码
def predict_year_by_year(self,tr,cut_point,duration,spontaneous,w1,alpha,w2):
        N = tr.shape[1] 
        pred = []
        for t in range(cut_point+1,cut_point+duration+1):
            delta_ct = spontaneous/w1*(numpy.exp(-w1*(t-1))-numpy.exp(-w1*t)) + \
                alpha/w2*(numpy.sum(numpy.exp(-w2*((t-1)-tr)))-numpy.sum(numpy.exp(-w2*(t-tr))))
            delta_ct = delta_ct[0,0]
            if len(pred) == 0:
                ct = N + delta_ct
            else :
                ct = pred[-1] + delta_ct
            tr = tr.tolist()[0]
            tr.extend([t for i in range(int(delta_ct))])
            tr = numpy.mat(tr)
            pred.append(ct)
        return pred
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号