当前位置: 首页>>代码示例>>C++>>正文


C++ Statistic::mean方法代码示例

本文整理汇总了C++中Statistic::mean方法的典型用法代码示例。如果您正苦于以下问题:C++ Statistic::mean方法的具体用法?C++ Statistic::mean怎么用?C++ Statistic::mean使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Statistic的用法示例。


在下文中一共展示了Statistic::mean方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: testStatistics

/**
 * Example of a test. To be completed.
 *
 */
bool testStatistics()
{
  unsigned int nbok = 0;
  unsigned int nb = 3;
  
  trace.beginBlock ( "Testing Statistics ..." );

  Statistic<double> stat;
  
  for(unsigned int k=0; k < 1000; k++)
    stat.addValue((double)k);
  
  stat.terminate();
  
  trace.info() << "Mean value = "<<stat.mean()  << std::endl;
  nbok += (stat.mean()==499.5) ? 1 : 0; 
  trace.info() << "Variance value = "<<stat.variance()<<std::endl;
  trace.info() << "Max value = "<<stat.max()<<std::endl;
  nbok += (stat.max()==999) ? 1 : 0; 
  trace.info() << "Min value = "<<stat.min()<<std::endl;
  nbok += (stat.min()==0)  ? 1 : 0; 
 
  trace.info() << "(" << nbok << "/" << nb << ") "
         << "true == true" << std::endl;
  trace.endBlock();
  
  return nbok == nb;
}
开发者ID:BorisMansencal,项目名称:DGtal,代码行数:32,代码来源:testStatistics.cpp

示例2: main

int main( int argc, char** argv )
{
  using namespace Z3i;
  Statistic<double> stats;
  unsigned int nbtries = ( argc > 1 ) ? atoi( argv[ 1 ] ) : 100;
  unsigned int nbpoints = ( argc > 2 ) ? atoi( argv[ 2 ] ) : 100;
  unsigned int diameter = ( argc > 3 ) ? atoi( argv[ 3 ] ) : 100;
  std::cout << "# Usage: " << argv[0] << " <nbtries> <nbpoints> <diameter>." << std::endl;
  std::cout << "# Test class COBANaivePlaneComputer. Points are randomly chosen in [-diameter,diameter]^3." << std::endl;
  std::cout << "# Integer nbtries nbpoints diameter time/plane(ms) E(comp) V(comp)" << std::endl;
  
 // Max diameter is ~20 for int32_t, ~500 for int64_t, any with BigInteger.
  trace.beginBlock ( "Testing class COBANaivePlaneComputer" );
  bool res = true 
    && checkPlanes<COBANaivePlaneComputer<Z3, DGtal::BigInteger> >( nbtries, diameter, nbpoints, stats );
  trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
  long t = trace.endBlock();
  stats.terminate();
  std::cout << "BigInteger" << " " << stats.samples()
            << " " << nbpoints
            << " " << diameter 
            << " " << ( (double) t / (double) stats.samples() )
            << " " << stats.mean()
            << " " << stats.variance()
            << std::endl;
  return res ? 0 : 1;
}
开发者ID:arnaudetitia,项目名称:DGtal,代码行数:27,代码来源:testCOBANaivePlaneComputer-benchmark.cpp

示例3: experimentWorkSpace

//層次
void experimentWorkSpace(){

	//A是產生完 B是計算完branch and dead ends
	//phase A
	GameControl* gameControl = GameControl::getInstance();

	//gameControl->file.open(".\\data\\gameboard20\\db_13.dat");//設定自動產生的關卡要存在哪邊
	//db_release = new GameDB(10, 10);
	//db_release->loadGames(".\\data\\gameboard10\\db_release10_phaseA.dat");
	//loadScore();
	/*GameDB* db = new GameDB(10, 10);
	db->loadGames(".\\data\\gameboard10\\db_release10_phaseB.dat");



	PersonalData* personalData = new PersonalData(".\\data\\gameboard10\\db_ALL_GAME_remove_same.dat");

	personalData->loadScore(".\\statistic\\");
	//personalData->printAllScore();

	Statistic ss;

	for(int i = 0; i < personalData->datas.size(); i ++){
		vector<ScoreData*> sortedScore = 
			personalData->sortbyDifficulty(PersonalData::DIFFICULTY, 
			                               personalData->datas[i]);
		vector<GameState*> complexState = GameControl::getInstance()->
			                              sortbyComplexity(GameControl::ASCENT, 
			                              personalData->getState(sortedScore));


	}*/

	//SimulationAnnealing sa(personalData);
	//GameParameter* p = new GameParameter(1);
	//sa.begin(p);
	
	
	GameDB* veryEasyDB = new GameDB();
	veryEasyDB->loadGames(".\\data\\gameboard10\\db_e2_VeryEasy.dat");

	GameDB* easyDB = new GameDB();
	easyDB->loadGames(".\\data\\gameboard10\\db_e2_Easy.dat");

	GameDB* normalDB = new GameDB();
	normalDB->loadGames(".\\data\\gameboard10\\db_e2_Normal.dat");

	GameDB* hardDB = new GameDB();
	hardDB->loadGames(".\\data\\gameboard10\\db_e2_Hard.dat");

	GameDB* veryHardDB = new GameDB();
	veryHardDB->loadGames(".\\data\\gameboard10\\db_e2_VeryHard.dat");

	vector<GameState*> pickVeryEasyStates = veryEasyDB->getRandomStates(2);
	vector<GameState*> pickEasyStates = easyDB->getRandomStates(3);
	vector<GameState*> pickNormalStates = normalDB->getRandomStates(3);
	vector<GameState*> pickHardStates = hardDB->getRandomStates(1);
	vector<GameState*> pickVeryHardStates = veryHardDB->getRandomStates(1);

	vector<GameState*> releaseStates = easyDB->merge(pickVeryEasyStates, pickEasyStates);
	releaseStates = easyDB->merge(releaseStates, pickNormalStates);
	releaseStates = easyDB->merge(releaseStates, pickHardStates);
	releaseStates = easyDB->merge(releaseStates, pickVeryHardStates);

	releaseStates = GameControl::getInstance()->sortbyComplexity(GameControl::ASCENT, releaseStates);

	easyDB->saveGames(".\\data\\gameboard10\\db_e2_release_random10.dat", releaseStates);

	Statistic ss;
	cout << ss.mean(Statistic::BRANCH, veryEasyDB->states) << endl;
	cout << ss.mean(Statistic::BRANCH, easyDB->states) << endl;
	cout << ss.mean(Statistic::BRANCH, normalDB->states) << endl;
	cout << ss.mean(Statistic::BRANCH, hardDB->states) << endl;
	cout << ss.mean(Statistic::BRANCH, veryHardDB->states) << endl;


	cout << "==============" << endl;
	cout << ss.mean(Statistic::DEADEND, veryEasyDB->states) << endl;
	cout << ss.mean(Statistic::DEADEND, easyDB->states) << endl;
	cout << ss.mean(Statistic::DEADEND, normalDB->states) << endl;
	cout << ss.mean(Statistic::DEADEND, hardDB->states) << endl;
	cout << ss.mean(Statistic::DEADEND, veryHardDB->states) << endl;
	cout << "==============" << endl;

	cout << ss.mean(Statistic::COMPLEXITY, veryEasyDB->states) << endl;
	cout << ss.mean(Statistic::COMPLEXITY, easyDB->states) << endl;
	cout << ss.mean(Statistic::COMPLEXITY, normalDB->states) << endl;
	cout << ss.mean(Statistic::COMPLEXITY, hardDB->states) << endl;
	cout << ss.mean(Statistic::COMPLEXITY, veryHardDB->states) << endl;

	//vector<GameState*> states = db->pickStates(personalData->puzzleDB->states, db->states);
	GameControl::getInstance()->states = veryEasyDB->states;
	gameControl->setStateIndex(0);
	//GameControl::getInstance()->sortSolvedSequence();
	//db->saveGames(".\\data\\gameboard10\\db_ALL_GAME_remove_same.dat", db->states);
	//system("pause");

}
开发者ID:dorgonman,项目名称:Cross_Block,代码行数:99,代码来源:main.cpp


注:本文中的Statistic::mean方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。