void report_distances(const valarray<double>& distances, const string& name, variables_map& args ) { if (not distances.size()) return; bool show_mean = args.count("mean"); bool show_median = args.count("median"); bool show_minmax = args.count("minmax"); if (not show_mean and not show_median and not show_minmax) show_median = true; if (show_minmax) cout<<" "<<name<<" in ["<<min(distances)<<", "<<max(distances)<<"]"<<endl; if (show_mean){ cout<<" E "<<name<<" = "<<distances.sum()/distances.size(); cout<<" [+- "<<sqrt(Var(distances))<<"]"<<endl; } if (show_median) { double P = args["CI"].as<double>(); pair<double,double> interval = central_confidence_interval(distances,P); cout<<" "<<name<<" ~ "<<median(distances); cout<<" ("<<interval.first<<", "<<interval.second<<")"<<endl; } }
double CMinimizerThread::ComputeChi2r(valarray<double> & chis, unsigned int n_params) { // Square the numerator, divide by the uncertainties chis *= chis; double chi2_sum = chis.sum(); // Now compute the sum dividied by (n_data - n_params - 1) return chi2_sum / (chis.size() - n_params - 1); }
log_double_t dirichlet_pdf(const valarray<double>& p,const valarray<double>& n) { assert(p.size() == n.size()); log_double_t Pr = 1; for(int i=0; i<p.size(); i++) Pr *= pow(log_double_t(p[i]),n[i]-1.0); // This term is constant in p Pr.log() += log_gamma(n.sum()); for(int i=0; i<p.size(); i++) Pr.log() -= log_gamma(n[i]); return Pr; }
inline double sum(const valarray<double>& v) { return v.sum(); }
double getsum(const valarray<double>& v) { return v.sum(); }