美文网首页
2019-05-26模拟Poisson分布、复合Poisson分

2019-05-26模拟Poisson分布、复合Poisson分

作者: Jin_Qiang | 来源:发表于2019-05-26 17:31 被阅读0次
    import numpy as np
    import matplotlib.pyplot as plt
    
    N = 20
    lam=20
    t = np.random.exponential(scale=1/lam![1.png](https://img.haomeiwen.com/i11516617/523f1ffcb6bdfcb1.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
    
    ![2.png](https://img.haomeiwen.com/i11516617/cf281136e8a2d9da.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
    , size=N)  #提取服从指数分数的随机数
    Sn = np.zeros(N)
    Nt = [i for i in range(N)]
    for i in range(0, N):
        Sn[i] = sum(t[:i+1]) #第i次跳跃发生时间
        
    plt.figure()
    plt.grid()
    plt.xlabel('t')
    plt.ylabel('N(t)')
    plt.title('one path of a Poisson process')
    for i in range(N-1):
        plt.plot((Sn[i], Sn[i+1]), (Nt[i], Nt[i]), color='r')
    
    
    Qt = np.zeros(N)
    #提取服从均匀分布的随机数,分布区间[0, 3]
    y = np.random.uniform(low=0.0, high=5.0, size=N) 
    for i in range(0, N):
        Qt[i] = sum(y[:i+1])
        
    plt.figure()
    plt.grid()
    plt.xlabel('t')
    plt.ylabel('Q(t)')
    plt.title('one path of a compound Poisson process')
    for i in range(N-1):
        plt.plot((Sn[i], Sn[i+1]), (Qt[i], Qt[i]), color='r')
    
    1.png 2.png

    相关文章

      网友评论

          本文标题:2019-05-26模拟Poisson分布、复合Poisson分

          本文链接:https://www.haomeiwen.com/subject/bxjftctx.html