Hey everyone
I have been trying to implement the following Fourier series in pymc3
with the mean value equal to 0. So far i have been using scan from theano to do so
with pm.Model() as model:
#Fourier coefficients
S_k = pm.Normal('S_k', mu=0.0, sigma=sigma_k,shape=N_k)
C_k = pm.Normal('C_k',mu=0.0,sigma=sigma_k,shape=N_k)
f,updates=theano.scan(fn=lambda t:tt.sum(C_k*tt.cos(omg_k*t)+S_k*tt.sin(omg_k*t)),
sequences=[t])
f_save=pm.Deterministic('f_save',f)
likelihood = pm.Normal('f_driv', mu=f, sigma=err_driv, observed=f_driv)
tracetransfer = pm.sample(1000,tune=1000,init='advi+adapt_diag',chains=2)
From what i understand theano scan is slow compared to a vectorized solution, so i was wondering if anyone has some ideas/tips on how to vectorize the sum in theano.
Thanks for your help everyone