Okay so i found the error while creating the example notebook. The yerr array had “dtype=float32” and i had to convert it to “dtype=float” to work. I think it was the extra infomation about the dtype that was messing with the model since it looked like
array([0.00485131, 0.00487679, 0.01067159, 0.00494462, 0.00560853,
0.00562166, 0.00541271, 0.0053869 , 0.00802224, 0.00387515,
0.00430117, 0.00468504, 0.00432127, 0.00454601, 0.00390065,
0.00520721, 0.00578553, 0.00405268, 0.00448521, 0.00422477,
0.00439943, 0.00501591, 0.00491921, 0.00525864, 0.0170183 ,
0.0238815 , 0.00497915, 0.0048724 , 0.00481433, 0.00570282,
0.02026841, 0.00499057, 0.00472333, 0.00661963, 0.00475204,
0.00480907, 0.00482606, 0.00537344, 0.00541538, 0.00564796,
0.00554904, 0.00553942, 0.01326797, 0.00609176, 0.00613547,
0.00639062, 0.00638895, 0.00599033, 0.00716414], dtype=float32)
while for the new one i have
yerr = np.array(magerr_ref1[mask], dtype=float)
yerr
array([0.00485131, 0.00487679, 0.01067159, 0.00494462, 0.00560853,
0.00562166, 0.00541271, 0.0053869 , 0.00802224, 0.00387515,
0.00430117, 0.00468504, 0.00432127, 0.00454601, 0.00390065,
0.00520721, 0.00578553, 0.00405268, 0.00448521, 0.00422477,
0.00439943, 0.00501591, 0.00491921, 0.00525864, 0.0170183 ,
0.0238815 , 0.00497915, 0.0048724 , 0.00481433, 0.00570282,
0.02026841, 0.00499057, 0.00472333, 0.00661963, 0.00475204,
0.00480907, 0.00482606, 0.00537344, 0.00541538, 0.00564796,
0.00554904, 0.00553942, 0.01326797, 0.00609176, 0.00613547,
0.00639062, 0.00638895, 0.00599033, 0.00716414])
For those interested here is the full model:
import numpy as np
import pymc3 as pm
X=[[57690.156444 ],
[57702.042152 ],
[57714.09288 ],
[57727.058406 ],
[57785.33735 ],
[57799.337204 ],
[57835.345248 ],
[57847.218598 ],
[57870.38101 ],
[57872.34736 ],
[57887.334724 ],
[57901.294798 ],
[57913.261906 ],
[57925.123674 ],
[57937.187432 ],
[57949.16307 ],
[57962.127284 ],
[57974.094412 ],
[57987.048386 ],
[58000.303966 ],
[58018.23316 ],
[58047.208566 ],
[58072.050364 ],
[58084.055702 ],
[58127.353694 ],
[58151.287814 ],
[58166.326436 ],
[58183.323268 ],
[58222.31519 ],
[58236.377956 ],
[58237.3749525],
[58250.340886 ],
[58263.305154 ],
[58276.365486 ],
[58289.241552 ],
[58307.182884 ],
[58320.122346 ],
[58332.115664 ],
[58344.081428 ],
[58356.048366 ],
[58368.331064 ],
[58380.28918 ],
[58433.114668 ],
[58445.050324 ],
[58458.058774 ],
[58517.347406 ],
[58529.33535 ],
[58541.3453 ],
[58569.380416 ]]
X=np.reshape(X,(len(X),1))
y=[-0.04021454, -0.04408264, 0.00086784, -0.03276062, -0.09445763,
-0.11571121, -0.0334301 , -0.08233452, -0.09807587, -0.02315331,
-0.02507591, 0.00783348, -0.05967522, -0.03184891, -0.05742645,
0.00561142, -0.02413559, -0.02518654, 0.01398849, 0. ,
0.07386398, 0.09370232, 0.09769058, 0.05272102, 0.04765701,
0.16421509, 0.0471611 , 0.00388718, -0.02775383, -0.0708313 ,
-0.12369347, -0.07772446, -0.09989738, -0.11494827, -0.09436607,
-0.0891819 , -0.01688957, 0.04362106, 0.03388023, 0.06066322,
0.11610603, 0.12976837, 0.23965454, 0.04725456, 0.04477501,
0.0041008 , 0.08264542, 0.02942657, 0.13908195]
yerr=[0.00485131, 0.00487679, 0.01067159, 0.00494462, 0.00560853,
0.00562166, 0.00541271, 0.0053869 , 0.00802224, 0.00387515,
0.00430117, 0.00468504, 0.00432127, 0.00454601, 0.00390065,
0.00520721, 0.00578553, 0.00405268, 0.00448521, 0.00422477,
0.00439943, 0.00501591, 0.00491921, 0.00525864, 0.0170183 ,
0.0238815 , 0.00497915, 0.0048724 , 0.00481433, 0.00570282,
0.02026841, 0.00499057, 0.00472333, 0.00661963, 0.00475204,
0.00480907, 0.00482606, 0.00537344, 0.00541538, 0.00564796,
0.00554904, 0.00553942, 0.01326797, 0.00609176, 0.00613547,
0.00639062, 0.00638895, 0.00599033, 0.00716414]
with pm.Model() as model:
ℓ = pm.Uniform('ℓ', lower=np.sqrt(5.0), upper=50.0*np.sqrt(2.0))
η = pm.Uniform('η', lower=0.0, upper=1.0)
cov = η**2 * pm.gp.cov.Exponential(1, ℓ)
gp = pm.gp.Latent(cov_func=cov)
f = gp.prior("f", X=X)
k = pm.Uniform('k', lower=1.0, upper=2.0)
y_ = pm.Normal("y", mu=f, sd=k*yerr, observed=y)
trace = pm.sample(2000)