simhawkes.py 文件源码

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

项目:academic 作者: xinchrome 项目源码 文件源码
def simhawkes(trseq,T1,T2,v,w1,alpha,w2):
    t = T1
    while t<T2:
        lam = v*numpy.exp(-w1*t) + numpy.sum(alpha*numpy.exp(-w2*(t-trseq)))
        #v*exp(-w1*t) + sum(alpha*exp(-w2*(t-trseq)));
        u = numpy.random.random() # rand();
        t = t+(-numpy.log(numpy.random.random())/float(lam)) #t+(-log(rand)/lam);
        lam2 = v*numpy.exp(-w1*t) + numpy.sum(alpha*numpy.exp(-w2*(t-trseq))) 
        #v*exp(-w1*t) + sum(alpha*exp(-w2*(t-trseq)));
        if t<T2 and u*lam<lam2:
             trseq = numpy.concatenate((trseq,numpy.mat(t)),axis=1) #[trseq;t];
        #end
        if trseq.shape[1] > 1e3: #length(trseq)>1e3
            break
        #end
    #end
    return trseq
    #ct = trseq

    #end
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号