Example #1
0
def main():
    (x, y) = LSM.data()
    (xwn, ywn) = LSM.data(Noise=True)
    lsm = LSM.LSM_L2(6)
    lsm.fit(x, y)
    lsm2 = LSM.LSM_L2(6)
    lsm2.fit(xwn, ywn)
    tics = 2 * pi * arange(0, 1, 0.02)
    lw = 5  #line width
    plt.subplot(211)
    plt.legend()
    plt.plot(x, y, 'ro', ms=10)
    plt.plot(tics, sin(tics), linewidth=lw, label="sin")
    plt.plot(tics, lsm.predict(tics), linewidth=lw, label="fitting")
    plt.legend(loc='lower right')

    plt.subplot(212)
    plt.xlim(0, 2 * pi)
    plt.ylim(-2, 2)
    plt.legend()
    plt.plot(xwn, ywn, 'ro', ms=10)
    plt.plot(tics, sin(tics), linewidth=lw, label="sin")
    plt.plot(tics, lsm2.predict(tics), linewidth=lw, label="fitting")
    plt.legend(loc='lower right')
    plt.show()
Example #2
0
def main():
    (x,y) = LSM.data()
    (xwn, ywn) = LSM.data(Noise=True)
    lsm = LSM.LSM_L2(6)
    lsm.fit(x,y)
    lsm2 = LSM.LSM_L2(6)
    lsm2.fit(xwn,ywn)
    tics = 2*pi*arange(0,1,0.02);
    lw = 5 #line width
    plt.subplot(211)
    plt.legend()
    plt.plot(x,y, 'ro', ms=10)
    plt.plot(tics,sin(tics), linewidth=lw, label="sin")
    plt.plot(tics,lsm.predict(tics), linewidth=lw, label="fitting");
    plt.legend(loc = 'lower right')

    plt.subplot(212)
    plt.xlim(0,2*pi)
    plt.ylim(-2,2)
    plt.legend()
    plt.plot(xwn,ywn, 'ro', ms=10)
    plt.plot(tics,sin(tics), linewidth=lw, label="sin")
    plt.plot(tics,lsm2.predict(tics), linewidth=lw, label="fitting");
    plt.legend(loc = 'lower right')
    plt.show()
Example #3
0
File: L2.py Project: PRMLiA/tsho
def main():
    (x,y) = LSM.data()
    (xwn, ywn) = LSM.data(Noise=True)
    lsm = LSM.LSM_L2(M=7, l=2.)
    tics = 2*pi*arange(0,1,0.02);
    lw = 5 #line width

    ls = power(7., range(-2,3))
    print(ls)
    for idcs in range(len(ls)):
        plt.subplot(len(ls),1,idcs+1)
        plt.xlim(0,2*pi+2)
        plt.ylim(-2,2)
        plt.legend()
        plt.plot(xwn,ywn, 'ro', ms=10)
        plt.plot(tics,sin(tics), linewidth=lw, label="sin")
        lsm.l = ls[idcs]
        lsm.fit(xwn,ywn)
        plt.plot(tics,lsm.predict(tics), linewidth=lw, label='l={:.1}'.format(ls[idcs]));
        plt.legend(loc = 'lower right')
    plt.show()
Example #4
0
def main():
    (x, y) = LSM.data()
    (xwn, ywn) = LSM.data(Noise=True, NL=0.3, N=10)
    lsm = LSM.LSM_L2(M=7, l=2.)
    tics = 2 * pi * arange(0, 1, 0.02)
    lw = 5  #line width

    ls = array([0.0, 0.1, 10, 100])
    print(ls)
    for idcs in range(len(ls)):
        plt.subplot(len(ls), 1, idcs + 1)
        plt.xlim(0, 2 * pi + 2)
        plt.ylim(-2, 2)
        plt.legend()
        plt.plot(xwn, ywn, 'ro', ms=10)
        plt.plot(tics, sin(tics), linewidth=lw, label="sin")
        lsm.l = ls[idcs]
        lsm.fit(xwn, ywn)
        plt.plot(tics,
                 lsm.predict(tics),
                 linewidth=lw,
                 label='l={:.1}'.format(ls[idcs]))
        plt.legend(loc='lower right')
    plt.show()