struct spa_gauss {
ad mu, sigma;
int n = s.size();
ad K = 0;
for(int i=0; i<n; i++){
K += mu * s(i) + 0.5 * s(i) * s(i) * sigma * sigma;
}
ad res = K - (s*y).
sum();
return res;
}
template<class Type>
return res;
}
};
template<class Type>
Type objective_function<Type>::operator() ()
{
Type sigma = exp(logSigma);
spa_gauss spa = {y, mu, sigma};
Type res = spa.eval_nldens(s);
return res;
}
License: