Beispiel #1
0
def sample_from( display = True ):
    test_x = [ [x] for x in numpy.arrayrange(0,5,.05) ]
    test_y = infpy.gp_sample_from( gp, test_x )

    if display:
        from pylab import figure, plot, show, fill, title
        figure()
        infpy.gp_plot_prediction( gp.X, test_y )
        title('Log likelihood: %f\n%s' % ( gp.log_p_y_given_X, gp.k.params ) )
        show()
Beispiel #2
0
def gp_ex_fixed_period():
    """Example of the fixed period kernel"""
    start, end = -4.0, 0.0
    X = infpy.gp_1D_X_range( start, end, 1.3 )
    # X = [ ]
    # X = [ [ 0.0 ] ]
    # X = [ [ 0.0 ], [ 1.0 ] ]
    # X = [ [ 0.0 ], [ -1.0 ], [ -2.0 ], [ -3.0 ], ]
    y = numpy.asarray( [ math.sin( 2.0 * math.pi * x[0] ) for x in X ] )
    # pylab.plot( [ x[0] for x in X ], [ y1 for y1 in y ] )
    # pylab.show()
    LN = infpy.LogNormalDistribution
    k = (
            infpy.FixedPeriod1DKernel( 1.0 )
            + infpy.noise_kernel( 0.1 )
    )
    gp = infpy.GaussianProcess( X, y, k )
    sample_X = infpy.gp_1D_X_range( start, end, 0.03 )
    y = infpy.gp_sample_from( gp, sample_X )
    ( y, V_f_star, log_p_y_given_X ) = gp.predict( sample_X )
    infpy.gp_plot_prediction( sample_X, y )
    infpy.gp_title_and_show( gp )