Exemplo n.º 1
0
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 Trigamma(double x) {
    if (x > 0.0 && x <= 1.0E-5) {
        return 1.0 / (x * x);
    } else if (x >= 49.0) {
        double inv = 1.0 / (x * x);
        //  1    1      1       1       1
        //  - + ---- + ---- - ----- + -----
        //  x      2      3       5       7
        //      2 x    6 x    30 x    42 x
        return 1.0 / x + inv / 2.0 + inv / x * (0.16666666666666666 - inv * (0.03333333333333333 + inv / 42.0));
    } else {
        return Trigamma(x + 1.0) + 1.0 / (x * x);
    }
}
Exemplo n.º 3
0
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);

}