Hi

In the following code, I am trying to implement a constant mean function from GaussianProcesses.jl. But it is throwing an error stating `no method matching MeanConst()`

```
using GaussianProcesses
n = 100;
x = 2π * rand(n);
y = sin.(x) + 0.2*randn(n);
#mZero = MeanZero()
mConst = MeanConst()
kern = SE(0.0,0.0) ## squared exponential kernel
logObsNoise = -1.0
gp = GP(x, y, mConst, kern, logObsNoise)
optimize!(gp)
plot(gp)
```

It is throwing the following error.

```
MethodError: no method matching MeanConst()
Closest candidates are:
MeanConst(::Float64) at ~/.julia/packages/GaussianProcesses/dOato/src/means/mConst.jl:23
Stacktrace:
[1] top-level scope
@ In[137]:5
```

As suggested in the error, the only method is `MeanConst(::Float64)`

, meaning you need to provide a constant as an argument - there is no default method with zero arguments.

1 Like

Thank you. This makes sense. I provided a value and it worked. Thanks again.

Dear Daniel

Thanks again for pointing out the correct way to feed the arguments. One more question, how can we feed the MeanLin function?

https://stor-i.github.io/GaussianProcesses.jl/latest/mean/#GaussianProcesses.MeanLin

Thanking you in advance.

Best regards,

Sourish

Judging from the source here GaussianProcesses.jl/mLin.jl at 1bcdf2dd8a988b91b0661e7ad1504d5fa66d9e65 · STOR-i/GaussianProcesses.jl · GitHub (bottom right button of that documentation), you just pass it a vector of coefficients.

Yes - that is what I tried. But facing some errors. Thanks again. I will figure it out. Thanks again.

Best regards,

Sourish

What was the error?

```
julia> MeanLin([1.0,2.0,3.0])
Type: MeanLin, Params: [1.0, 2.0, 3.0]
```

Dear Daniel:

Thanks again for your generous help. I tried your code:

```
MeanLin([1.0,2.0,3.0])
```

and I am getting this error.

```
MethodError: no method matching MeanLin(::Vector{Float64})
Closest candidates are:
MeanLin() at In[161]:1
```

Do I need to update my system?

You might’ve accidentally re-defined the function, e.g. maybe something you did

```
MeanLin() = ...
```

or similar. You can see this from `In[161]:1`

being the location of the method, when really it should be somewhere in GaussianProcesses.jl. Once you restart, it’ll be fixed

Oh dear - yes possible. Let me restart my session.

Sourish