src/ffs/ffs_direct.c
int ffs_direct_results(ffs_trial_arg_t * trial) {

  int ntrial, nlambda, nsuccess;
  int n, nstates, ntry, nprune, nto;
  int nsum_trial = 0, nsum_prune = 0, nsum_success = 0, nsum_nto = 0;
  double f1, tsum, wt, lambda, plambda;

  dbg_return_if(trial == NULL, -1);

  mpilog(trial->log, "\n");
  mpilog(trial->log, "Conditional probabilities\n");
  mpilog(trial->log, "-------------------------\n");

  ffs_init_ntrials(trial->init, &ntrial);
  ffs_result_nkeep(trial->result, 1, &nstates);
  ffs_param_nlambda(trial->param, &nlambda);

  mpilog(trial->log,
	 "                  states   forw.                        Prod.of\n");
  mpilog(trial->log,
	 "index      lambda   kept  trials  success pruned   to   weights\n");
  mpilog(trial->log,
	 "----------------------------------------------------------------\n");

  plambda = 1.0;

  for (n = 1; n <= nlambda; n++) {
    ffs_param_lambda(trial->param, n, &lambda);
    ffs_result_weight(trial->result, n, &wt);
    ffs_result_nkeep(trial->result, n, &nstates);
    ffs_result_prune(trial->result, n, &nprune);
    ffs_result_nto(trial->result, n, &nto);

    if (n > 1) {
      ffs_param_ntrial(trial->param, n - 1, &ntry);
      if (wt > 1.0*ntry) wt = 1.0*ntry;   /* Can happen with pruning */
      if (ntry > 0) plambda *= (wt / ntry);
    }

    ffs_param_ntrial(trial->param, n, &ntry);

    nsuccess = 0;
    if (n < nlambda) {
      ffs_result_trial_success(trial->result, n+1, &nsuccess);
      if (nsuccess == 0) plambda = 0.0; /* zero if no trials & no success */
    }

    mpilog(trial->log, "  %3d %11.4e  %5d %7d %7d %7d %4d %11.4e\n", n, lambda,
	   nstates, ntry, nsuccess, nprune, nto, plambda);

    nsum_trial += ntry;
    nsum_success += nsuccess;
    nsum_prune += nprune;
    nsum_nto += nto;
  }

  mpilog(trial->log,
	 "----------------------------------------------------------------\n");
  mpilog(trial->log, "(totals)                 %7d %7d %7d %4d\n", nsum_trial,
	 nsum_success, nsum_prune, nsum_nto);

  ffs_result_aflux_tsum_final(trial->flux, &tsum);
  ffs_result_aflux_ncross_final(trial->flux, &n);
  f1 = n/tsum;
  ffs_result_summary_stat_set(trial->summary, f1, plambda);

  mpilog(trial->log, "\n");
  mpilog(trial->log, "Probability P(B|A):     %12.6e\n", plambda);
  mpilog(trial->log, "Flux * P(B|A):          %12.6e\n", (n/tsum)*plambda);

  return 0;
}
/*****************************************************************************
 *
 *  ffs_direct_results
 *
 *  Display the results in a human-readable format
 *
 *****************************************************************************/
ffs_direct_results
Display the results in a human-readable format
ffs_direct_results Display the results in a human - readable format
int ffs_direct_results(ffs_trial_arg_t * trial) {
  int ntrial, nlambda, nsuccess;
  int n, nstates, ntry, nprune, nto;
  int nsum_trial = 0, nsum_prune = 0, nsum_success = 0, nsum_nto = 0;
  double f1, tsum, wt, lambda, plambda;
  dbg_return_if(trial == NULL, -1);
  mpilog(trial->log, "\n");
  mpilog(trial->log, "Conditional probabilities\n");
  mpilog(trial->log, "-------------------------\n");
  ffs_init_ntrials(trial->init, &ntrial);
  ffs_result_nkeep(trial->result, 1, &nstates);
  ffs_param_nlambda(trial->param, &nlambda);
  mpilog(trial->log,
	 "                  states   forw.                        Prod.of\n");
  mpilog(trial->log,
	 "index      lambda   kept  trials  success pruned   to   weights\n");
  mpilog(trial->log,
	 "----------------------------------------------------------------\n");
  plambda = 1.0;
  for (n = 1; n <= nlambda; n++) {
    ffs_param_lambda(trial->param, n, &lambda);
    ffs_result_weight(trial->result, n, &wt);
    ffs_result_nkeep(trial->result, n, &nstates);
    ffs_result_prune(trial->result, n, &nprune);
    ffs_result_nto(trial->result, n, &nto);
    if (n > 1) {
      ffs_param_ntrial(trial->param, n - 1, &ntry);
      if (wt > 1.0*ntry) wt = 1.0*ntry;   
      if (ntry > 0) plambda *= (wt / ntry);
    }
    ffs_param_ntrial(trial->param, n, &ntry);
    nsuccess = 0;
    if (n < nlambda) {
      ffs_result_trial_success(trial->result, n+1, &nsuccess);
      if (nsuccess == 0) plambda = 0.0; 
    }
    mpilog(trial->log, "  %3d %11.4e  %5d %7d %7d %7d %4d %11.4e\n", n, lambda,
	   nstates, ntry, nsuccess, nprune, nto, plambda);
    nsum_trial += ntry;
    nsum_success += nsuccess;
    nsum_prune += nprune;
    nsum_nto += nto;
  }
  mpilog(trial->log,
	 "----------------------------------------------------------------\n");
  mpilog(trial->log, "(totals)                 %7d %7d %7d %4d\n", nsum_trial,
	 nsum_success, nsum_prune, nsum_nto);
  ffs_result_aflux_tsum_final(trial->flux, &tsum);
  ffs_result_aflux_ncross_final(trial->flux, &n);
  f1 = n/tsum;
  ffs_result_summary_stat_set(trial->summary, f1, plambda);
  mpilog(trial->log, "\n");
  mpilog(trial->log, "Probability P(B|A):     %12.6e\n", plambda);
  mpilog(trial->log, "Flux * P(B|A):          %12.6e\n", (n/tsum)*plambda);
  return 0;
}
int ffs_direct_results ( ffs_trial_arg_t * trial ) { int ntrial , nlambda , nsuccess ; int n , nstates , ntry , nprune , nto ; int nsum_trial = 0 , nsum_prune = 0 , nsum_success = 0 , nsum_nto = 0 ; double f1 , tsum , wt , lambda , plambda ; dbg_return_if ( trial == NULL , -1 ) ; mpilog ( trial -> log , " \n " ) ; mpilog ( trial -> log , " \n " ) ; mpilog ( trial -> log , " \n " ) ; ffs_init_ntrials ( trial -> init , & ntrial ) ; ffs_result_nkeep ( trial -> result , 1 , & nstates ) ; ffs_param_nlambda ( trial -> param , & nlambda ) ; mpilog ( trial -> log , " \n " ) ; mpilog ( trial -> log , " \n " ) ; mpilog ( trial -> log , " \n " ) ; plambda = 1.0 ; for ( n = 1 ; n <= nlambda ; n ++ ) { ffs_param_lambda ( trial -> param , n , & lambda ) ; ffs_result_weight ( trial -> result , n , & wt ) ; ffs_result_nkeep ( trial -> result , n , & nstates ) ; ffs_result_prune ( trial -> result , n , & nprune ) ; ffs_result_nto ( trial -> result , n , & nto ) ; if ( n > 1 ) { ffs_param_ntrial ( trial -> param , n - 1 , & ntry ) ; if ( wt > 1.0 * ntry ) wt = 1.0 * ntry ; if ( ntry > 0 ) plambda *= ( wt / ntry ) ; } ffs_param_ntrial ( trial -> param , n , & ntry ) ; nsuccess = 0 ; if ( n < nlambda ) { ffs_result_trial_success ( trial -> result , n + 1 , & nsuccess ) ; if ( nsuccess == 0 ) plambda = 0.0 ; } mpilog ( trial -> log , " \n " , n , lambda , nstates , ntry , nsuccess , nprune , nto , plambda ) ; nsum_trial += ntry ; nsum_success += nsuccess ; nsum_prune += nprune ; nsum_nto += nto ; } mpilog ( trial -> log , " \n " ) ; mpilog ( trial -> log , " \n " , nsum_trial , nsum_success , nsum_prune , nsum_nto ) ; ffs_result_aflux_tsum_final ( trial -> flux , & tsum ) ; ffs_result_aflux_ncross_final ( trial -> flux , & n ) ; f1 = n / tsum ; ffs_result_summary_stat_set ( trial -> summary , f1 , plambda ) ; mpilog ( trial -> log , " \n " ) ; mpilog ( trial -> log , " \n " , plambda ) ; mpilog ( trial -> log , " \n " , ( n / tsum ) * plambda ) ; return 0 ; }
ffs_direct_results
  Display the results in a human-readable format
ffs_direct_results Display the results in a human - readable format
/* Can happen with pruning */ /* zero if no trials & no success */