# Trying to sample my Gaussian Process with MCMC

**URL:** <https://discourse.julialang.org/t/trying-to-sample-my-gaussian-process-with-mcmc/78342>\
**Category:** General Usage\
**Tags:** gaussian-process\
**Created:** [March 23, 2022, 4:28pm UTC](https://discourse.julialang.org/t/trying-to-sample-my-gaussian-process-with-mcmc/78342 "2022-03-23T16:28:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mirror63](https://avatars.discourse-cdn.com/v4/letter/m/7ba0ec/32.png) [@mirror63](https://discourse.julialang.org/u/mirror63)\
**Post date:** [March 23, 2022, 4:28pm UTC](https://discourse.julialang.org/t/trying-to-sample-my-gaussian-process-with-mcmc/78342/1 "2022-03-23T16:28:06Z")

</div>

Hello I am using GuassianProcessess.jl, I have been looking at their tutorial ([Simple GP Regression · GaussianProcesses.jl](https://stor-i.github.io/GaussianProcesses.jl/latest/Regression/)) and implement it. Likewise, I want to implement a kernel with summing its value. Now I would like run a chain to optimize the hyper parameters. But I am running into this error, can anybody help me?

```julia
using Random

Random.seed!(20140430)
# Training data
n=10; #number of training points
x = 2π * rand(n); #predictors
y = sin.(x) + 0.05*randn(n); 

#Select mean and covariance function
#here values are log scaled. 
mZero = MeanZero() #Zero mean function
kern1 = Periodic(log(1.0), log(1.0), log(1.5)) #Sqaured exponential kernel (note that hyperparameters are on the log scale)
kern2 = Noise(log(0.01))
kern = kern1+kern2 # log standard deviation of observation noise (this is optional)
gp = GP(x,y,mZero,kern, 0) 

μ, σ² = predict_y(gp,range(0,stop=2π,length=100));

mcmc(gp)

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/f/2/f218143db0c0ceff977e4cd14188768fbad1635b.png)

---

<div class="post-metadata">

**Author:** ![dlakelan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlakelan/32/8491_2.png) [@dlakelan](https://discourse.julialang.org/u/dlakelan)\
**Post date:** [March 23, 2022, 7:02pm UTC](https://discourse.julialang.org/t/trying-to-sample-my-gaussian-process-with-mcmc/78342/2 "2022-03-23T19:02:36Z")

</div>

Try replacing `0` with `0.0` in all locations in your code
