def test_levy_walk(self):
     (un_sample, A, B, sample) = levy_walk(
         alpha=0.66,
         beta=0.99,
         sample_length=10,
         size_max=83000,
         velocity=1.0,
         f_min=8,
         f_max=83000,
         s_min=0.8,
         s_max=430,
         duration=1000,
         b_c=2,
         )
     
     (un_sample, A, B, sample) = levy_walk(
         alpha=0.66,
         beta=0.99,
         sample_length=10,
         size_max=83000,
         velocity=1.0,
         f_min=8,
         f_max=83000,
         s_min=0.8,
         s_max=430,
         duration=1000,
         b_c=1,
         )
Exemple #2
0
    def test_levy_walk(self):
        (un_sample, A, B, sample) = levy_walk(
            alpha=0.66,
            beta=0.99,
            sample_length=10,
            size_max=83000,
            velocity=1.0,
            f_min=8,
            f_max=83000,
            s_min=0.8,
            s_max=430,
            duration=1000,
            b_c=2,
        )

        (un_sample, A, B, sample) = levy_walk(
            alpha=0.66,
            beta=0.99,
            sample_length=10,
            size_max=83000,
            velocity=1.0,
            f_min=8,
            f_max=83000,
            s_min=0.8,
            s_max=430,
            duration=1000,
            b_c=1,
        )
 def test_levy_walk_return_sample_length(self):
     import numpy as N
     duration = 1000.0
     sample_length = 10.0
     test_len = 10
     for i in range(test_len):
         (un_sample, A, B, sample) = levy_walk(
             alpha=0.66,
             beta=0.99,
             sample_length=sample_length,
             size_max=83000,
             velocity=1.0,
             f_min=8,
             f_max=83000,
             s_min=0.8,
             s_max=430,
             duration=duration,
             b_c=2,
             )
         (X,Y,T) = zip(*sample)
         print 'NB SAMPLE', int(N.ceil(duration/sample_length)), len(set(T))
         self.assertEqual(N.ceil(duration/sample_length), len(list(set(T))))
Exemple #4
0
 def test_levy_walk_return_sample_length(self):
     import numpy as N
     duration = 1000.0
     sample_length = 10.0
     test_len = 10
     for i in range(test_len):
         (un_sample, A, B, sample) = levy_walk(
             alpha=0.66,
             beta=0.99,
             sample_length=sample_length,
             size_max=83000,
             velocity=1.0,
             f_min=8,
             f_max=83000,
             s_min=0.8,
             s_max=430,
             duration=duration,
             b_c=2,
         )
         (X, Y, T) = zip(*sample)
         print 'NB SAMPLE', int(N.ceil(duration / sample_length)), len(
             set(T))
         self.assertEqual(N.ceil(duration / sample_length),
                          len(list(set(T))))
Exemple #5
0
def run_example_levy_walk_w_plots():
    import numpy as N
    import pylab as plt
    from scikits.statsmodels.tools.tools import ECDF

    from complex_systems.mobility.levy_walk import levy_walk
    from complex_systems.mobility.distance import distance

    alpha = 0.9
    beta = 0.9
    f_min = 1.0
    f_max = 100.0
    s_min = 1.0
    s_max = 100.0
    velocity = 5.0

    (un_sampled, A, B, sampled) = levy_walk(
        alpha=alpha,
        beta=beta,
        sample_length=10.0,
        size_max=10000,
        velocity=velocity,
        f_min=f_min,
        f_max=f_max,
        s_min=s_min,
        s_max=s_max,
        duration=1000,
        b_c=2,
        )

    (X, Y, T) = zip(*un_sampled)
    (X_sampled, Y_sampled, T_sampled) = zip(*sampled)
    print T_sampled, X_sampled, Y_sampled

    plt.figure()
    plt.plot(X_sampled, Y_sampled, 'ro-')
    plt.plot(X, Y, 'o-')

    ecdf = ECDF(A)
    x = N.linspace(min(A), max(A))
    y = 1 - ecdf(x)

    ax1 = plt.subplot(121)
    plt.loglog(x, y, 'r', linewidth=2.0)
    plt.xlim(1, max(A))
    plt.ylim(min(y), max(y))
    plt.grid(True, which='both')
    plt.xlabel('Distance [m]')
    plt.ylabel('P(X > x)')

    ecdf = ECDF(B)
    x = N.linspace(min(B), max(B))
    y = 1 - ecdf(x)
    ax2 = plt.subplot(122, sharey=ax1)
    plt.setp( ax2.get_yticklabels(), visible=False)
    plt.loglog(x, y, 'r', linewidth=2.0)
    plt.xlim(1, max(B))
    plt.ylim(min(y), max(y))
    plt.grid(True, which='both')
    plt.xlabel('Pause Time [mins]')
    plt.savefig('levywalk.pdf')
    plt.savefig('levywalk.eps')
    #plt.ylabel('P(X > x)')

    D = distance(X, Y)
    D_sampled = distance(X_sampled, Y_sampled)
    Dcumsum = N.cumsum(D)
    Dcumsum_sampled = N.cumsum(D_sampled)

    plt.figure()
    plt.plot(T[0:len(D)], Dcumsum, 'o-r', linewidth=2.0)
    plt.plot(T_sampled[0:len(Dcumsum_sampled)], Dcumsum_sampled, 'o-',
             linewidth=2.0)
    plt.ylabel('Cumulative distance traveled by the random walker (meters)'
               )
    plt.xlabel('Time (mins)')
    plt.show()