本文整理汇总了C++中DataSource::IsParam方法的典型用法代码示例。如果您正苦于以下问题:C++ DataSource::IsParam方法的具体用法?C++ DataSource::IsParam怎么用?C++ DataSource::IsParam使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataSource
的用法示例。
在下文中一共展示了DataSource::IsParam方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Fit
ExplicitEquation::FitError ExplicitEquation::Fit(DataSource &series, double &r2) {
r2 = 0;
if (series.IsExplicit() || series.IsParam())
return InadequateDataSource;
if (series.GetCount() < coeff.GetCount())
return SmallDataSource;
ptrdiff_t numUnknowns = coeff.GetCount();
VectorXd x(numUnknowns);
for (int i = 0; i < numUnknowns; ++i)
x(i) = coeff[i];
Equation_functor functor;
functor.series = &series;
functor.fSource = this;
functor.unknowns = numUnknowns;
functor.datasetLen = series.GetCount();
NumericalDiff<Equation_functor> numDiff(functor);
LevenbergMarquardt<NumericalDiff<Equation_functor> > lm(numDiff);
// ftol is a nonnegative input variable that measures the relative error desired in the sum of squares
lm.parameters.ftol = 1.E4*NumTraits<double>::epsilon();
// xtol is a nonnegative input variable that measures the relative error desired in the approximate solution
lm.parameters.xtol = 1.E4*NumTraits<double>::epsilon();
lm.parameters.maxfev = maxFitFunctionEvaluations;
int ret = lm.minimize(x);
if (ret == LevenbergMarquardtSpace::ImproperInputParameters)
return ExplicitEquation::ImproperInputParameters;
if (ret == LevenbergMarquardtSpace::TooManyFunctionEvaluation)
return TooManyFunctionEvaluation;
double mean = series.AvgY();
double sse = 0, sst = 0;
for (int64 i = 0; i < series.GetCount(); ++i) {
double y = series.y(i);
if (!IsNull(y)) {
double res = y - f(series.x(i));
sse += res*res;
double d = y - mean;
sst += d*d;
}
}
r2 = 1 - sse/sst;
return NoError;
}