本文整理汇总了C++中GModelPar::factor_error方法的典型用法代码示例。如果您正苦于以下问题:C++ GModelPar::factor_error方法的具体用法?C++ GModelPar::factor_error怎么用?C++ GModelPar::factor_error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GModelPar
的用法示例。
在下文中一共展示了GModelPar::factor_error方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_observations_optimizer
/***********************************************************************//**
* @brief Test observations optimizer.
*
* @param[in] mode Testing mode.
*
* This method supports two testing modes: 0 = unbinned and 1 = binned.
***************************************************************************/
void TestOpenMP::test_observations_optimizer(const int& mode)
{
// Create Test Model
GTestModelData model;
// Create Models conteners
GModels models;
models.append(model);
// Time iterval
GTime tmin(0.0);
GTime tmax(1800.0);
// Rate : events/sec
double rate = RATE;
// Create observations
GObservations obs;
// Add some observation
for (int i = 0; i < 6; ++i) {
// Random Generator
GRan ran;
ran.seed(i);
// Allocate events pointer
GEvents *events;
// Create either a event list or an event cube
if (mode == UN_BINNED) {
events = model.generateList(rate,tmin,tmax,ran);
}
else {
events = model.generateCube(rate,tmin,tmax,ran);
}
// Create an observation
GTestObservation ob;
ob.id(gammalib::str(i));
// Add events to the observation
ob.events(*events);
ob.ontime(tmax.secs()-tmin.secs());
obs.append(ob);
// Delete events pointer
delete events;
}
// Add the model to the observation
obs.models(models);
// Create a GLog for show the interations of optimizer.
GLog log;
// Create an optimizer.
GOptimizerLM opt(log);
opt.max_stalls(50);
// Optimize
obs.optimize(opt);
// Get the result
GModelPar result = (*(obs.models()[0]))[0];
// Check if converged
test_assert(opt.status()==0, "Check if converged",
"Optimizer did not converge");
// Check if value is correct
test_value(result.factor_value(),RATE,result.factor_error()*3);
// Return
return;
}