Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A question about white noise #985

Open
HanyangHenry-Wang opened this issue Jun 28, 2022 · 0 comments
Open

A question about white noise #985

HanyangHenry-Wang opened this issue Jun 28, 2022 · 0 comments

Comments

@HanyangHenry-Wang
Copy link

I define a kernel: GPy.kern.RBF(input_dim=1)+ GPy.kern.White(input_dim=1) and set the variance to be 16: m.kern.white.variance.fix(16). At the same time, I also set Gaussian_noise.variance to be 0: m.Gaussian_noise.variance.fix(0.0). Then I trainned the model and printed the variance of the observed point. Since I set the variance of white noise to be 16, I would expected the printed varaince is also 16. However, it is not. Could anyone please give me any hints about why this would happen?

The code is shown below:

import GPy
import numpy as np
from matplotlib import pyplot as plt
import math
from matplotlib import cm
import matplotlib;matplotlib.rcParams['figure.figsize'] = (8,5)
from scipy.stats import norm

X_sample = np.array([65.90839098, 3.42578164, 94.28049275, 67.15595707, 62.12945463,
86.23608086, 49.95824059, 61.69834602, 65.60985616, 82.10544337,
17.78284136, 10.73349743, 52.72038104, 55.16478482, 80.37307872,
61.67559055, 38.32262376, 43.63278254, 30.95413331, 48.02303168,
30.07533029, 8.54384364, 75.36399076, 33.44540949, 77.50964475,
69.56168432, 12.7087159 , 83.97033861, 26.95214725, 74.85074055,
93.37182696, 79.55644837, 74.4371696 , 97.7020137 , 69.99849814,
85.39974238, 6.73668038, 97.92367334, 27.80713194, 27.16078012,
97.00206296, 69.60144159, 66.13993086, 46.34517758, 49.20531501,
34.58281279, 7.82319509, 5.29995882, 8.27315924, 12.9793999 ])

Y_sample = np.array([ 1.9318772 , 0.48676711, 0.1598817 , 0.56495963, 0.87248468,
0.30614613, 3.70536682, 1.34703027, 0.86764436, 0.26602824,
1.76858056, 0.83367018, 1.92433637, 1.99344327, 0.34902601,
0.8204964 , 25.46785322, 7.79681189, 18.73552574, 1.77590455,
17.82596369, 0.56422196, 0.28723818, 38.42662269, 0.22558383,
0.23646561, 0.47469529, 0.09767295, 6.02168149, 0.14659177,
0.07567237, 0.18865004, 0.27170018, 0.10783688, 0.40515622,
0.17372068, 0.31550655, 0.09527466, 1.64899802, 1.10552056,
0.10999749, 0.63947079, 0.98716834, 32.41018846, 18.32256269,
3.57756452, 0.4165166 , 0.41004365, 0.48388013, 0.60502143])

#define the kernel and train the GP model
k1 = GPy.kern.RBF(input_dim=1)+ GPy.kern.White(input_dim=1)
m = GPy.models.GPRegression(X_sample.reshape(-1, 1), Y_sample.reshape(-1, 1), k1)
m.Gaussian_noise.variance.fix(0.0)
m.kern.white.variance.fix(16) #I define the variance to be 16

m.optimize()

pre_var = np.array([m.predict(np.array([x]).reshape(1, 1))[1] for x in X_sample])
print(pre_var) #I expect the variance to be 16 because that is what I defined, but the result is not

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant