Learn R Programming

gpHist (version 0.1)

gpHistPredict: gpHistPredict Function

Description

This function is used to predict new sample means. For prediction of the variance the function gpHistVariance is used. This has been done intentially, to provide the chance not to predict the variance if it is not required. Also keep in mind, that you need the data that you used for training of GP to make predictions.

Usage

gpHistPredict(GP, X,x_pred)

Arguments

GP

Gaussian Process object returned by gpHist function

X

Original data that has been used for the training of the GP process.

x_pred

New data that is to be predicted

Value

If the function fails or spotts an error in the parameters NAN is returned. Otherwise the predicted sample mean is returned.

Details

X and x_pred need to be matrix in correct format. Each row is one example of D dimensions.

See Also

Package Overview: gpHist-Package

Function for estimation of the GP: gpHist

Function for prediction of new sample variance: gpHistVariance

Function for hyperparameter estimation: estimateHyperParameters

Examples

Run this code
# NOT RUN {
testFn = function(x){
  y = sin(2*pi*x*2) 
}

#Get data
X = seq(0,1,0.1)
Y = testFn(X)

#Call gpHist function
gp_hist = gpHist(matrix(X),matrix(Y),sigma=0.01)

# New data to predict
x_pred = matrix(seq(0,1,0.01))

#Prediction
prediction = gpHistPredict(gp_hist,matrix( X), x_pred)

# Plot results
plot(X,Y)
lines(x_pred, prediction,col='red')

legend('topleft',legend=c('Data', 'Approximation'), col=c('black','red') ,lty=c(NA,1),pch=c(1,NA))

# }

Run the code above in your browser using DataLab