Esempio n. 1
0
int main(int argc, char** argv)
{
  utest_binom_transform(1, 1);
  utest_binom_transform_gsl(1, 1);

  double prior[2] = {0.0, 3.3};
  double post[2];
  double rs[2];

  binom_solver(prior, rs, 0.0, 1e-8, 100);
  printf("rs = %g, %g\n", rs[0], rs[1]);

  binom_post(prior, post, 1, 1, 1e-8, 100);
  printf("post = %g, %g\n", post[0], post[1]);

  return 0;
}
Esempio n. 2
0
int main(int argc, char** argv)
{
  // Function tests
  utest_binom_transform_gsl(1, 1);
  utest_binom_transform(1, 1);

  double prior[2] = {0.0, 3.3};
  double post[2];
  double rs[2];
  double ival[2] = {0.1, 0.1};

  // Exact
  Rprintf("Exact...\n");
  solver(prior, rs, ival, 0.0, 1e-8, 100, &binom_transform_gsl);
  Rprintf("rs = %g, %g\n", rs[0], rs[1]);

  binom_post(prior, post, 1, 1, ival, 1e-8, 100);
  Rprintf("post = %g, %g\n", post[0], post[1]);

  // Newton
  Rprintf("Exact with Jacobian...\n");
  binom_solver(prior, rs, ival, 0.0, 1e-8, 100);
  Rprintf("rs = %g, %g\n", rs[0], rs[1]);

  binom_post(prior, post, 1, 1, ival, 1e-8, 100);
  Rprintf("post = %g, %g\n", post[0], post[1]);

  // Class tests
  Rprintf("Exact (by class)...\n");
  CUBSSolver cs(&binom_transform_gsl);
  cs.solve(prior, rs, 0.0, 1e-8, 100);
  Rprintf("rs = %g, %g\n", rs[0], rs[1]);

  BinomUpdate binom;
  binom.update(prior, post, 1, 1, 1e-8, 100);
  Rprintf("post = %g, %g\n", post[0], post[1]);

  return 0;
}