Ejemplo n.º 1
0
def example_4():
    dt = 0.01
    X = np.linspace(0, 30, 600)
    sum = np.random.rand(X.shape[0]) / 3
    X = 2 * np.sin(2 * np.pi * X * 2.1) + 3 * np.sin(
        2 * np.pi * X * 0.3) + 1 * np.sin(2 * np.pi * X * 0.57) * X + sum
    #X = X[::2]
    p = 50
    win = 100
    yr = X
    X = nn.force_recurrent_gap(X, 10, 3, 0)
    print(X.shape)
    yn, SSE = NGD_sample_HONU('LNU', X, yr, p, win, 20, 30, 50, 0.05)
    divide = 1
    subplot(2, 1, 1)
    plot(yr * divide, 'k')
    plot(yn * divide, 'g')
    err = (yr - yn[:yr.shape[0]]) * divide
    #err = coarse(err,12,24*4,[0,100],3)
    #plot(np.sqrt(err**2),'r')
    plot(err, 'r')
    subplot(2, 1, 2)
    plot(SSE)

    #X = np.linspace(0,30,8177*2)
    #sum = np.random.rand(X.shape[0])/5
    #X = 2*np.sin(2*np.pi*X*2.1)+3*np.sin(2*np.pi*X*0.3)+ sum + 1*np.sin(2*np.pi*X*0.77)+ sum
    #plot(X,'y')
    show()
Ejemplo n.º 2
0
def example_2():
    X = np.linspace(0, 70, 2400)
    sum = np.random.rand(X.shape[0]) / 5
    X = 0.5 * np.sin(2 * np.pi * X * 0.4) + 0.3 * np.sin(
        2 * np.pi * X * 0.5)  # + sum

    p = 50
    win = 300
    yr = X

    X = nn.force_recurrent_gap(X, 15, 5, 0)

    yn, SSE = batch_MLP('LM', 5, X, yr, p, win, 10, 50, 3, 0.005)
    #plot(J.T)
    show()
    divide = 10
    subplot(2, 1, 1)
    title('Predikce')
    plot(yr * divide, 'k')
    plot(yn * divide, 'g')
    err = (yr - yn[:yr.shape[0]]) * divide
    plot(err, 'r')

    subplot(2, 1, 2)
    plot(SSE)
    title('SSE')
    #err = coarse(err,12,24*4,[0,100],3)
    #plot(np.sqrt(err**2),'r')
    show()
Ejemplo n.º 3
0
def example_3():
    dt = 0.01
    X = np.linspace(0, 30, 1000)
    sum = np.random.rand(X.shape[0])

    X = 2 * np.sin(2 * np.pi * X * 2.1) + 3 * np.sin(
        2 * np.pi * X * 0.3) + 1 * np.sin(2 * np.pi * X * 0.77)  #+ sum
    #X = X[::2]
    p = 50
    win = 100
    yr = X
    yr[700:706] = 0
    X = nn.force_recurrent_gap(X, 15, 5, 0)
    print(X.shape)
    #yn = LM_batch('LNU',X,yr,p,win,30,10,10,0.05)
    yn, EA, EAP = CGD_batch('LNU', X, yr, p, win, 5, 30, 3)
    divide = 1
    subplot(3, 1, 1)
    plot(yr * divide, 'k')
    plot(yn * divide, 'g')
    err = (yr - yn[:yr.shape[0]]) * divide
    plot(err, 'r')
    subplot(3, 1, 2)
    plot(EA)
    subplot(3, 1, 3)
    plot(EAP)

    #err = coarse(err,12,24*4,[0,100],3)
    #plot(np.sqrt(err**2),'r')

    #X = np.linspace(0,30,8177*2)
    #sum = np.random.rand(X.shape[0])/5
    #X = 2*np.sin(2*np.pi*X*2.1)+3*np.sin(2*np.pi*X*0.3)+ sum + 1*np.sin(2*np.pi*X*0.77)+ sum
    #plot(X,'y')
    show()
Ejemplo n.º 4
0
def example_1():
    N = 3000
    rand = np.random.rand(N)
    X = np.linspace(0, 45, N)
    sum = np.random.rand(X.shape[0]) / 15

    X = 0.5 * np.sin(2 * np.pi * X * 0.4) + 0.3 * np.sin(
        2 * np.pi * X * 0.8) + sum
    max = np.amax(X)
    X = X / max

    yr = X
    n = 10
    X = nn.force_recurrent_gap(X, n, 5, 0)

    p = 100
    win = 200

    yn, SSE = XGD_sample_MLP('NGD', 10, X, yr, p, win, 40, 30, 15, 0.01)

    divide = 1
    subplot(2, 1, 1)
    plot(yr * max, 'k')
    plot(yn * max, 'g')
    err = (yr - yn[:yr.shape[0]]) * max

    plot(err, 'r')
    subplot(2, 1, 2)
    plot(SSE)
    show()
Ejemplo n.º 5
0
def example_5():
    X = np.linspace(0, 30, 1000)
    sum = np.random.rand(X.shape[0]) / 3
    X = 2 * np.sin(2 * np.pi * X * 2.1) + 3 * np.sin(
        2 * np.pi * X * 0.3) + 1 * np.sin(2 * np.pi * X * 0.77) + sum
    p = 30
    win = 200
    yr = X
    X = nn.force_recurrent_gap(X, 15, 5, 0)
    #print(X.shape)
    yn = LM_batch('LNU', X, yr, p, win, 30, 10, 10, 0.05)
    #yn,EA,EAP = CGD_batch('LNU',X,yr,p,win,5,30,3)
    #yn = LM_batch('LNU',X,yr,p,win,30,10,10,0.05)

    divide = 1
    subplot(1, 1, 1)
    plot(yr * divide, 'k')
    plot(yn * divide, 'g')
    err = (yr - yn[:yr.shape[0]]) * divide
    plot(err, 'r')
    show()