本文整理汇总了C++中Statistic类的典型用法代码示例。如果您正苦于以下问题:C++ Statistic类的具体用法?C++ Statistic怎么用?C++ Statistic使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Statistic类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Statistic
void Startphase::setStatistics(vector<Player*>* gamePlayers) {
//Select Desired statitics to follow
int option;
Statistic* stat = new Statistic();
do {
cout << "Select desired statistics to follow: " << endl;
cout << "0. Follow Number Of Countries per player;" << endl;
cout << "1. Follow Total Number of Armies per player" << endl;
cout << "2. Follow Number of cards per player" << endl;
cout << "3. Done" << endl;
cin >> option;
switch (option) {
case 0:
stat = new CountriesStat(stat); // Decorate statistics with Country Stats
break;
case 1:
stat = new ArmiesStat(stat); // Decorate statistics with Armies Stats
break;
case 2:
stat = new CardsStat(stat); // Decorate statistics with Cards Stats
}
} while (option != 3);
for (int i = 0; i < gamePlayers->size(); i++) {
(*gamePlayers)[i]->attach(stat);
stat->attachPlayer((*gamePlayers)[i]);
}
}
示例2: 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;
}
示例3: main
int main() {
Statistic statistic;
statistic.setUDPTraffic(11);
statistic.WriteToFile("/re/unitTest/GenerateDataForML/aaa", "aaa");
return 0;
}
示例4: PrintStats
void PrintStats(const std::string& title, const Statistic& stats)
{
using namespace DPL::Colors::Text;
printf("\n%sResults [%s]: %s\n", BOLD_GREEN_BEGIN, title.c_str(), BOLD_GREEN_END);
printf("%s%s%3d%s\n", CYAN_BEGIN, "Total tests: ", stats.GetTotal(), CYAN_END);
printf(" %s%s%3d%s\n", CYAN_BEGIN, "Succeeded: ", stats.GetPassed(), CYAN_END);
printf(" %s%s%3d%s\n", CYAN_BEGIN, "Failed: ", stats.GetFailed(), CYAN_END);
printf(" %s%s%3d%s\n", CYAN_BEGIN, "Ignored: ", stats.GetIgnored(), CYAN_END);
}
示例5: ShowStatictics
void MultyBuffer::ShowStatictics(Statistic& statistic, std::ofstream& resFile)
{
for(auto i = statistic.begin(); i != statistic.end(); ++i)
{
const double average = static_cast<double>(i->second.types) / static_cast<double>( i->second.seconds);
resFile.write( reinterpret_cast< const char* >(& ( i->first ) ), sizeof( boost::uint32_t ) );
resFile.write( reinterpret_cast< const char* >( &average ), sizeof(double) );
}
}
示例6: main
int main()
{
Statistic stats;
stats.Add(5);
stats.Add(10);
stats.Add(12);
stats.Add(6);
stats.Add(15);
stats.Add(4);
stats.getNumbers();
stats.getAverage();
stats.getSTD();
Statistic stats1;
stats1.Add(5.4);
stats1.Add(10);
stats1.Add(12.3);
stats1.Add(6.4);
stats1.Add(15);
stats1.Add(4.332);
stats1.getNumbers();
stats1.getAverage();
stats1.getSTD();
//using https://www.easycalculation.com/statistics/standard-deviation.php
//I verified that my equations were correct
return 0;
}
示例7: QString
void NoGUI::loadState()
{
IniFile iniFile;
iniFile.setFilename( QString("%1/state.ini").arg(m_filePath) );
if(!iniFile.ready()) return;
if(m_monteCarlo) m_monteCarlo->loadState(&iniFile);
m_geometry->loadState(&iniFile);
for(QVariant &variant : m_statistics) {
Statistic *statistic = variant.value<Statistic*>();
statistic->loadState(&iniFile);
}
}
示例8: CountValidLast
long CountValidLast( StatList *byStat )
{
Statistic *p;
long i = 0, count = 0;
while( (p=byStat->GetStat(i)) && i<byStat->num ){
if ( p->GetVisitIn() != 0 )
count++;
i++;
}
return count;
}
示例9: startQuery
void QueryLoggingSolver::startQuery(const Query& query, const char* typeName,
const Query* falseQuery,
const std::vector<const Array*> *objects) {
Statistic *S = theStatisticManager->getStatisticByName("Instructions");
uint64_t instructions = S ? S->getValue() : 0;
logBuffer << queryCommentSign << " Query " << queryCount++ << " -- "
<< "Type: " << typeName << ", "
<< "Instructions: " << instructions << "\n";
printQuery(query, falseQuery, objects);
startTime = getWallTime();
}
示例10: badMove
void EndlessGameWidget::badMove()
{
// Add sound effect
PublicGameSounds::addSound(PublicGameSounds::BadMove);
statistic.changeStatistic(Statistic::BadMoveCount, 1, true);
}
示例11: startQuery
void startQuery(const Query& query, const char *typeName,
const ref<Expr> *evalExprsBegin = 0,
const ref<Expr> *evalExprsEnd = 0,
const Array * const* evalArraysBegin = 0,
const Array * const* evalArraysEnd = 0) {
Statistic *S = theStatisticManager->getStatisticByName("Instructions");
uint64_t instructions = S ? S->getValue() : 0;
os << "# Query " << queryCount++ << " -- "
<< "Type: " << typeName << ", "
<< "Instructions: " << instructions << "\n";
printer->printQuery(os, query.constraints, query.expr,
evalExprsBegin, evalExprsEnd,
evalArraysBegin, evalArraysEnd);
startTime = getWallTime();
}
示例12: main
int main (int argc, char **argv)
{
clock_t t1,t2;
t1 = clock();
/*
* Parses command line
*/
try {
Options::Get().Parse(argc, argv);
}
catch (exception &e) {
cerr << e.what() << "\n";
Options::Get().print_usage();
exit(0);
}
cout << "Statistic: " << Options::Get().statistic << "\n";
/*
* Initiates Statistic factory
*/
try {
AddAllStatistics();
} catch (exception &e){
cerr << e.what() << "\n";
exit(0);
}
/*
* Read the multiple alignment
*/
Msa msa(Options::Get().input_fname);
/*
* Calculate the statistic & print it
*/
Statistic * stat = StatisticFactory::CreateByName(Options::Get().statistic);
stat->calculate(msa);
stat->print(msa);
delete stat;
/*
* Print time
*/
t2 = clock();
cout << "Mstatx computed in "<< (t2 - t1) / (double)CLOCKS_PER_SEC <<" seconds\nResults are written in " << Options::Get().output_fname << "\n\n";
return 0;
}
示例13: startQuery
void startQuery(const Query& query, const char *typeName, const std::vector<const Array*>* objects=NULL)
{
Statistic *S = theStatisticManager->getStatisticByName("Instructions");
uint64_t instructions = S ? S->getValue() : 0;
os << ";SMTLIBv2 Query " << queryCount++ << " -- "
<< "Type: " << typeName << ", "
<< "Instructions: " << instructions << "\n";
printer->setQuery(query);
if(objects!=NULL)
printer->setArrayValuesToGet(*objects);
printer->generateOutput();
os << "\n";
startTime = getWallTime();
}
示例14: merge
void Registry::merge(const Registry &other)
{
for (const_iterator i = other.begin(); i != other.end(); i++)
{
boost::ptr_map<std::string, Statistic>::iterator pos = statistics.find(i->getName());
if (pos == statistics.end())
{
Statistic *clone = i->clone();
std::string name = clone->getName();
statistics.insert(name, clone);
}
else
{
pos->second->merge(*i);
}
}
}
示例15: DBIO_LoadStatistic
static long DBIO_LoadStatistic( VDinfoP VDptr, Statistic *stat, gzFile fh, long useOtherNames, char *id )
{
long dataread = 0;
if ( !fh ) return 0;
// read one statistic
if ( stat ) {
dataread += gzread( fh, stat ,sizeof(Statistic) );
if ( useOtherNames == NAMEIS_NORMAL || useOtherNames == NAMEIS_IP ) {
if ( stat->GetName() && stat->length>0 ){
char *name;
name = stat->AllocateName( stat->length );
dataread += ReadString( fh, name, stat->length );
}
} else
if ( (long)stat->GetName() == NAMEIS_STATIC )
{
if( !mystrcmpi( "hour", id ) ) RestoreHourNames( stat );
else if( !mystrcmpi( "wkday", id ) ) RestoreWeekdaysNames( stat );
else if( !mystrcmpi( "wdays", id ) ) RestoreHourNames( stat );
else if( !mystrcmpi( "oper", id ) ) RestoreOpersysNames( stat );
else if( !mystrcmpi( "errs", id ) ) RestoreErrorsNames( stat );
else if( !mystrcmpi( s_errorsWithTopReferralsTag, id ) ) RestoreErrorsNames( stat );
else if( !mystrcmpi( "pages", id ) ) RestoreStatisticName( stat, VDptr->byFile );
else if( !mystrcmpi( "down", id ) ) RestoreStatisticName( stat, VDptr->byFile );
else if( !mystrcmpi( "audio", id ) ) RestoreStatisticName( stat, VDptr->byFile );
else if( !mystrcmpi( "video", id ) ) RestoreStatisticName( stat, VDptr->byFile );
else if( !mystrcmpi( s_brokenLinkReferalsTag, id ) ) RestoreStatisticName( stat, VDptr->byRefer );
else if( !mystrcmpi( s_intBrokenLinkReferalsTag, id ) ) RestoreStatisticName( stat, VDptr->byRefer );
else stat->name = NULL;
}
} else {
// read to where? empty area just incase
Statistic Lstat;
dataread += gzread( fh, &Lstat ,sizeof(Statistic) );
if ( Lstat.GetName() && !useOtherNames ) {
char tmp[1024];
dataread += gzread( fh, tmp , stat->length );
}
if ( (long)stat->GetName() == NAMEIS_STATIC )
stat->name = NULL;
}
return dataread;
}