コード例 #1
0
    proc = np.cumsum(seq,axis=1);
    return proc


if __name__ == "__main__":
    n_dims = 1;
    N_samples = 1000;
    seq1 = genrand_seq(n_dims,N_samples);
    seq1 = gen_proc(seq1);

    seq2 = genrand_seq(n_dims,N_samples);
    seq2 = gen_proc(seq2);

    plt.plot(np.transpose(seq1))
    cdf = df.gen_cdf(seq1[0],100,1)
    pdf = df.gen_pdf(seq1[0],100,1)

    rho = [-0.95,-0.5, 0, 0.5 ,0.95]
    rho = np.array(rho);
    rho2 = np.sqrt(1-np.power(rho,2))

    for i in range(5):
        corr_seq = rho[i]*seq1 + rho2[i]*seq2;
        #corr_seq = np.transpose(corr_seq);
        q = plt.figure()
        plt.plot(corr_seq,seq1,'o');
        title = 'Correlation Coefficient - ' + str(rho[i])
        q.suptitle(title)
    plt.show()

コード例 #2
0
def gen_rand_seq(N):
    rand_seq = np.random.rand(N);
    return rand_seq



if __name__ == "__main__":
    N = 1000000;
    lambda_poisson = .7;
    delta = 1;
    p = lambda_poisson*delta;
    threshold = 1-p;

    seq = gen_rand_seq(N);
    loc_seq = threshold_loc(seq,threshold);
    (ia_times,n_arrivals) = calc_interarrival_times(loc_seq);
    x_val = np.arange(n_arrivals);
    #dist_hist = np.histogram(ia_times,10);
    (cdf_freq_val,cdf_xvals) = df.gen_cdf(ia_times,10,1);
    (pdf_val,pdf_xval) = df.gen_pdf(ia_times,10,1);
    #plt.plot(cdf_xvals,cdf_freq_val,'o')
    #plt.figure()
    #plt.plot(pdf_val,pdf_xval)
    plt.show()
    #plt.figure
    #plt.plot(dist_hist[0])

    #plt.figure
    #plt.plot(x_val,ia_times)