Пример #1
0
    '''fig = plt.figure()
    plt.plot(x1[:,0], x1[:,1], 'b+', markersize = 12)
    plt.plot(x2[:,0], x2[:,1], 'r+', markersize = 12)
    pc = plt.contour(t1, t2, np.reshape(p2/(p1+p2), (t1.shape[0],t1.shape[1]) ))
    fig.colorbar(pc)
    plt.grid()
    plt.axis([-4, 4, -4, 4])
    plt.show()'''

    meanfunc = [ ['means.meanConst'] ] 
    covfunc  = [ ['kernels.covSEard'] ]   
    likfunc = [ ['lik.likErf'] ]
    inffunc = [ ['inf.infEP'] ]

    hyp = hyperParameters()
    hyp.mean = np.array([-2.842117459073954])
    hyp.cov  = np.array([0.051885508906388,0.170633324977413,1.218386482861781])

    '''vargout = gp(hyp, inffunc, meanfunc, covfunc, likfunc, x, y, t, np.ones((n,1)) )
    a = vargout[0]; b = vargout[1]; c = vargout[2]; d = vargout[3]; lp = vargout[4]'''

    '''fig = plt.figure()
    plt.plot(x1[:,0], x1[:,1], 'b+', markersize = 12)
    plt.plot(x2[:,0], x2[:,1], 'r+', markersize = 12)
    pc = plt.contour(t1, t2, np.reshape(np.exp(lp), (t1.shape[0],t1.shape[1]) ))
    fig.colorbar(pc)
    plt.grid()
    plt.axis([-4, 4, -4, 4])
    plt.show()'''
Пример #2
0
    '''plt.plot(x,y,'b+',markersize=12)
    plt.axis([-1.9,1.9,-0.9,3.9])
    plt.grid()
    plt.xlabel('input x')
    plt.ylabel('output y')
    plt.show()'''

    z = np.array([np.linspace(-1.9,1.9,101)]).T # u test points evenly distributed in the interval [-7.5, 7.5]
    ## DEFINE parameterized covariance function
    meanfunc = [ ['means.meanSum'], [ ['means.meanLinear'] , ['means.meanConst'] ] ]
    covfunc  = [ ['kernels.covMatern'] ]
    inffunc  = ['inf.infExact']
    likfunc  = ['lik.likGauss']

    ## SET (hyper)parameters
    hyp = hyperParameters()

    hyp.cov = np.array([np.log(0.25),np.log(1.0),np.log(3.0)])
    hyp.mean = np.array([0.5,1.0])
    sn = 0.1; hyp.lik = np.array([np.log(sn)])

    #_________________________________
    # STANDARD GP:
    ## PREDICTION 
    '''vargout = gp(hyp,inffunc,meanfunc,covfunc,likfunc,x,y,None,None,False)
    print "nlml = ",vargout[0]
    vargout = gp(hyp,inffunc,meanfunc,covfunc,likfunc,x,y,z)
    ym = vargout[0]; ys2 = vargout[1]
    m  = vargout[2]; s2 = vargout[3]
    ## Plot results
    plotter(z,ym,ys2,x,y,[-1.9, 1.9, -0.9, 3.9])'''
Пример #3
0
    n,D = x.shape

    ## DEFINE parameterized covariance function
    covfunc = [ ['kernels.covSum'], [ ['kernels.covSEiso'],[['kernels.covProd'],[['kernels.covPeriodic'],['kernels.covSEiso']]],\
                ['kernels.covRQiso'],['kernels.covSEiso'],['kernels.covNoise'] ] ]

    ## DEFINE parameterized mean function
    meanfunc = [ ['means.meanZero'] ]      

    ## DEFINE parameterized inference and liklihood functions
    inffunc = ['inf.infExact']
    likfunc = ['lik.likGauss']

    ## SET (hyper)parameters
    hyp = hyperParameters()

    ## SET (hyper)parameters for covariance and mean
    hyp.cov = np.array([np.log(67.), np.log(66.), np.log(1.3), np.log(1.0), np.log(2.4), np.log(90.), np.log(2.4), \
                np.log(1.2), np.log(0.66), np.log(0.78), np.log(1.6/12.), np.log(0.18), np.log(0.19)])
    hyp.mean = np.array([])

    sn = 0.1
    hyp.lik = np.array([np.log(sn)])

    #_________________________________
    # STANDARD GP:
    ### TEST POINTS
    xs = np.arange(2004+1./24.,2024-1./24.,1./12.)
    xs = xs.reshape(len(xs),1)