https://github.com/GPflow/GPflow
Revision f5bc26e4a4c15aa3221c5c6b67964cf14987611c authored by James Hensman on 24 August 2016, 11:54:58 UTC, committed by GitHub on 24 August 2016, 11:54:58 UTC
2 parent s ee40ad5 + 0f8e58c
Raw File
Tip revision: f5bc26e4a4c15aa3221c5c6b67964cf14987611c authored by James Hensman on 24 August 2016, 11:54:58 UTC
Merge branch 'master' into badge
Tip revision: f5bc26e
reference.py
import numpy as np

def referenceRbfKernel( X, lengthScale, signalVariance ):
    (nDataPoints, inputDimensions ) = X.shape
    kernel = np.zeros( (nDataPoints, nDataPoints ) )
    for row_index in range( nDataPoints ):
        for column_index in range( nDataPoints ):
            vecA = X[row_index,:]
            vecB = X[column_index,:]
            delta = vecA - vecB
            distanceSquared = np.dot( delta.T, delta )
            kernel[row_index, column_index ] = signalVariance * np.exp( -0.5*distanceSquared / lengthScale** 2)
    return kernel


def referencePeriodicKernel( X, lengthScale, signalVariance, period ):
    # Based on the GPy implementation of standard_period kernel
    base = np.pi * (X[:, None, :] - X[None, :, :]) / period
    exp_dist = np.exp( -0.5* np.sum( np.square(  np.sin( base ) / lengthScale ), axis = -1 ) )
    return signalVariance * exp_dist
    
back to top