本文整理匯總了C++中eigen::VectorXd::mean方法的典型用法代碼示例。如果您正苦於以下問題:C++ VectorXd::mean方法的具體用法?C++ VectorXd::mean怎麽用?C++ VectorXd::mean使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類eigen::VectorXd
的用法示例。
在下文中一共展示了VectorXd::mean方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1:
double Model::n1CDF(Eigen::VectorXd &d) {
gsl_function F;
F.function = &n1PDF;
F.params = &d;
double result, error;
// integration sometimes fails
gsl_set_error_handler_off();
int limit = 10000;
gsl_integration_workspace *w = gsl_integration_workspace_alloc(limit);
double epsabs = 0, epsrel = 1e-7;
double lower = 0, upper;
const double chi = 2,
sdI = 1; // following assumes these values. do not change these.
int status = gsl_integration_qagiu(&F, lower, epsabs, epsrel, limit, w,
&result, &error);
if (status != GSL_SUCCESS) {
double mean_drift = d.mean();
if (mean_drift > d(0)) {
lower = (chi - 0.98) / (mean_drift + 2 * sdI);
} else {
lower = (chi - 0.98) / (d(0) + 2 * sdI);
}
upper = 0.02 * chi / (mean_drift - 2 * sdI);
size_t neval;
status = gsl_integration_qng(&F, lower, upper, epsabs, epsrel, &result,
&error, &neval);
}
if (status != GSL_SUCCESS) {
// std::cout << "Integration Failed" << std::endl;
// result = GSL_NAN;
result = 0.0;
}
gsl_integration_workspace_free(w);
return result;
}
示例2: mean
double mean(Eigen::VectorXd &v)
{
return v.mean();
}