void IGMeasurementError::initFromList(Rcpp::List const &init_list) { NormalVarianceMixtureBaseError::initFromList(init_list); if(init_list.containsElementNamed("nu")) nu = Rcpp::as < double >( init_list["nu"]); else nu = 1.; EV = 1.; // not true it is the mode is alpha/(alpha - 1) EiV = 1.; npars += 1; digamma_nu = Digamma(nu); trigamma_nu = Trigamma(nu); int i = 0; if( init_list.containsElementNamed("Vs" )){ Rcpp::List Vs_list = init_list["Vs"]; Vs.resize(Vs_list.length()); for( Rcpp::List::iterator it = Vs_list.begin(); it != Vs_list.end(); ++it ) { Vs[i++] = Rcpp::as < Eigen::VectorXd >( it[0]); } }else throw("in IGMeasurementError::initFromList Vs must be set! \n"); }
double Digamma(double x) { if (x > 0.0 && x <= 1.0E-5) { return -0.5772156649015329 - 1.0 / x; } else if (x >= 49.0) { double inv = 1.0 / (x * x); return log(x) - 0.5 / x - inv * (0.08333333333333333 + inv * (0.008333333333333333 - inv / 252.0)); } else { return Digamma(x + 1.0) - 1.0 / x; } }
void IGMeasurementError::step_nu(double stepsize) { double nu_temp = -1; dnu /= ddnu; while(nu_temp < 0) { nu_temp = nu - stepsize * dnu; stepsize *= 0.5; if(stepsize <= 1e-16) throw("in IGMeasurementError:: can't make nu it positive \n"); } nu = nu_temp; EV = 1.; // not true it is the mode that is 1. EiV = 1. ; ddnu = 0; digamma_nu = Digamma(nu); trigamma_nu = Trigamma(nu); }