Example #1
0
int drawSpeed(Graphics *gra, int posX, int posY){

	// 速度表示部の背景を白くする
	SolidBrush b(Color(180,255,255,255));
	backGra->FillRectangle(&b, posX, posY, 200, 14);
	// フォント設定
	Font font(L"MS Pゴシック",10);
	// 文字色
	SolidBrush strBrush(Color::Black);
	// 文字列作成
	char tmp[256];
	sprintf(tmp, "R:%.1fkbps S:%.1fkbps", 
		BYTES_TO_KBPS(stats.getPerSecond(Stats::BYTESIN)-stats.getPerSecond(Stats::LOCALBYTESIN)),
		BYTES_TO_KBPS(stats.getPerSecond(Stats::BYTESOUT)-stats.getPerSecond(Stats::LOCALBYTESOUT)));
	_bstr_t bstr(tmp);
	// 文字表示範囲指定
	StringFormat format;
	format.SetAlignment(StringAlignmentCenter);
	RectF r((REAL)posX, (REAL)posY, (REAL)200, (REAL)14);
	// 文字描画
	gra->DrawString(bstr, -1, &font, r, &format, &strBrush);



	return posY + 15;
}
Example #2
0
int main(int argc, char * argv[])
{
    Stats s;
    string str;
    int temp1;	  //a temp variable to get the year data
    float temp2;		//a temp variable to get the month data
    float temp3;		//a temp variable to get the CO2 level data

    cout << argv[0] << " - " << argv[1] << endl;

    ifstream inFile;
    inFile.open(argv[1]);

    do
    {
        inFile >> str;
    } while (str != "MLO");	//To throw away the text we don't need

    do
    {
        inFile >> temp1;
        inFile >> temp2;
        inFile >> temp3;
        str = " ";
        inFile >> str;
        s.addVar(temp3);
    } while (str == "MLO");    //To read the text we need till there is nothing.

    s.showData();	//show the data
    s.clearData();	//clear the data

    inFile.close();
    return 0;
}
Example #3
0
void TTest::perform(const int index, Stats& stats)
{

  // This can happen when we do one last t-test at the end of
  // a simulation and we've already done one recently enough
  // that we don't have any samples for this one.
  // If there is only one sample should we skip that also?
  if (_stat2.getNrSamples() == 0)
    {
      return;
    }

  if (_stat1.getNrSamples() == 0)
    {
      _stat1 = _stat2;
    }

  // If no bacteria it always clearance, regardless of the type of t-test used.
  if (stats.getTotExtMtb() + stats.getTotIntMtb() == 0)
    {
      stats.setStatus(index, GR_CLEARANCE);
      return;
    }

  double v = degreesOfFreedom();

  evaluate(index, stats, v);

  _stat1 = _stat2;
  _stat2.reset();
}
Example #4
0
/*! \brief Filter paired-end reads by patterns
 *
 *  \param[in]  reads1_f    an input stream of paired-end read 1 sequences
 *  \param[in]  reads2_f    an input stream of paired-end read 2 sequences
 *  \param[out] ok1_f       an output stream to write filtered paired-end read 1 sequences to
 *  \param[out] ok2_f       an output stream to write filtered paired-end read 2 sequences to
 *  \param[out] stats1      statistics on first parts of processed reads
 *  \param[out] stats2      statistics on second parts of processed reads
 *  \param[in]  root        a root of the trie structure used to perform string matching
 *  \param[in]  patterns    a vector of patterns for read filtration
 *  \param[in]  length      the read length threshold
 *  \param[in]  dust_k      the DUST algorithm parameter
 *  \param[in]  dust_cutoff the DUST score threshold
 *  \param[in]  errors      the number of resolved mismatches between a read and
 *                          a pattern
 */
void filter_paired_reads(std::ifstream & reads1_f, std::ifstream & reads2_f,
                         std::ofstream & ok1_f, std::ofstream & ok2_f,
                         Stats & stats1, Stats & stats2,
                         Node * root, std::vector <std::pair<std::string, Node::Type> > const & patterns, int errors)
{
    Seq read1;
    Seq read2;
    int processed = 0;

    while (read1.read_seq(reads1_f) && read2.read_seq(reads2_f)) {
        ReadType type1 = check_read(read1.seq, root, patterns, 0, 0, 0, errors);
        ReadType type2 = check_read(read2.seq, root, patterns, 0, 0, 0, errors);
        if (type1 == ReadType::ok && type2 == ReadType::ok) {
            read1.write_seq(ok1_f);
            read2.write_seq(ok2_f);
            stats1.update(type1, true);
            stats2.update(type2, true);
        } else {
            stats1.update(type1, false);
            stats2.update(type2, false);
        }

        processed += 1;
        if (processed % 1000000 == 0) {
            std::cerr << "Processed: " << processed << std::endl;
        }
    }
}
void createReport(Stats runners)
{
	cout << endl << "Tulsa Tigers Track Team" << endl << endl;
	cout << "Average 100 yard-dash time: " << runners.average() << " seconds" << endl;
	cout << "Slowest runner: " << runners.lowest() << " seconds" << endl;
	cout << "Fastest runner: " << runners.highest() << " seconds" << endl;
}
Example #6
0
int main() {
	S = Stats();
	string queryFile,data,output;
	cin >> queryFile >> data >> output;  
	Q.setQuery(queryFile);
	inputData(data);
	clock_t s = clock();
	//This constructs our index on the basis of min dimension
	T.initialize(Data,1);
	//This constructs our index on the basis of n-k+1_th or k_th min dimension based on whether K<=D/2 or K>D/2
	R.initialize((Q.K<=Q.D/2?Q.D-Q.K+1:Q.K));
	//This is the list of pruned out points sorted on the basis of time-stamp(in our case the min attribute value)
	P.initialize(0);
	
	indexedTwoPass();
	clock_t e = clock();
	S.setRunningTime(e-s);
	
	cout << "IndexedTwoPass\t" << data << "\t" << Q.K << "\t" ;  
	S.printStats();
	
	sort(S.skyIds.begin(),S.skyIds.end());
	ofstream out(output);
	assert(out.is_open());
	out.precision(dbl::digits10);
	for(int i=0;i < S.skyIds.size();i++) {
		out << S.skyIds[i]+1 << " ";
		for(int j=0;j<(int)Data[S.skyIds[i]].attr.size();j++)
			out << scientific <<Data[S.skyIds[i]].attr[j] << " ";
		out << endl;
	}
	return 0;
}
Example #7
0
    /**
     * Exchange the statistics between instances.
     * @param[in|out] myStats starts with the local information and is populated with the aggregation of the global
     *                        information on instance 0. Not changed on other instances.
     * @param query the query context
     */
    void exchangeStats(Stats& myStats, shared_ptr<Query>& query)
    {
        if (query->getInstanceID() != 0)
        {
            /* I am not instance 0, so send my stuff to instance 0 */
            shared_ptr<SharedBuffer> buf = myStats.marshall();
            /* Non-blocking send. Must be matched by a BufReceive call on the recipient */
            BufSend(0, buf, query);
        }
        else
        {
            /*I am instance 0, receive stuff rom all other instances */
            for (InstanceID i = 1; i<query->getInstancesCount(); ++i)
            {
                /* Blocking receive. */
                shared_ptr<SharedBuffer> buf = BufReceive(i, query);
                Stats otherInstanceStats(buf);
                /* add data to myStats */
                myStats.merge(otherInstanceStats);
            }
        }

        /* Note: at the moment instance 0 IS synonymous with "coordinator". In the future we may move to a more
         * advanced multiple-coordinator scheme.
         */
    }
Example #8
0
	void DoStatsReset(CommandSource &source)
	{
		Stats *stats = Serialize::GetObject<Stats *>();
		stats->SetMaxUserCount(UserListByNick.size());
		source.Reply(_("Statistics reset."));
		return;
	}
Example #9
0
// where all the action happens. 
int main(int argc, char *argv[]) {

  if (argc != 3) {
    cerr << "USAGE: 'progName' numHiddenNodes numEpochs" << endl;
    exit(1);
  }

  int numHidden = atoi(argv[1]);
  int numEpochs = atoi(argv[2]);
 
  bool debug = true;
  
  Stats *s = new Stats(numEpochs, debug);


  // train and save weights along the way
  s->getWeights(numHidden, 0.05);
  
  // gather stats on the networks every 10 epochs by loading the saved weights and running the net on the test set. Saves stat results to a .csv file
  for (int i = 0; i <= numEpochs; i+=10) {
    if (debug)
      cout << 100*(double)i/(double)(numEpochs) << "\tpercent tested\n";
    stringstream fileName;
    fileName << numHidden << "-" << i << ".weights";
      
    // run test set on the net saved in the numHidden-epoch.weights file and gather stats on it
    s->testWeights(fileName.str(), numHidden, 0.05);
  }
}
Example #10
0
int CALLBACK DlgProc( HWND hw, UINT msg, WPARAM wp, LPARAM lp ) {
	switch( msg ) {
	case WM_CLOSE:
		ExitDialog(hw);
		break;
	case WM_INITDIALOG:
	{
		std::ifstream  f(fname.c_str(), std::ios::binary );
		if( !f.is_open() ) 
		{
			return ErrorEndDialog(hw);
		}
		if(reader.LoadFromFile(f)<1) 
		{ 
			return ErrorEndDialog(hw);
		}
		stats.make_static();
		hwAnswer =	GetDlgItem( hw, ED_ANSWER );
		hwInfo =	GetDlgItem( hw, ST_INFO );
		hwFalse =	GetDlgItem( hw, BN_FALSE );
		hwTrue =	GetDlgItem( hw, BN_TRUE );
		hwUnchecked = GetDlgItem( hw,  BN_UNCHECKED);
		hwAuto =	GetDlgItem( hw, CH_AUTO );
		hwNext =	GetDlgItem( hw, BN_NEXT );
		hwOnly =	GetDlgItem( hw, CH_ONLY );
		hwStatStr =	GetDlgItem( hw, ST_STAT );
		hwStatBn =	GetDlgItem( hw, BN_STAT );
		
		LoadStatistic(hwAnswer, hwTrue, hwUnchecked, hwNext);
		LoadStatisticState(hwStatStr);
		stats.set_changed(false);
		SendMessage(      hwOnly,		(UINT) BM_SETCHECK, !stats.isAllCheked(), 0);
		SendMessage(      hwAuto,		(UINT) BM_SETCHECK,true, 0);
	}
	break;
	case WM_COMMAND:
		switch( LOWORD(wp) ) 
		{

		case BN_EXIT:
			ExitDialog(hw);
			break;
		case BN_NEXT:
		case BN_PREV:
			Go(LOWORD(wp)-1005);// from resurse file constant
			break;
		case BN_UNCHECKED:
		case BN_TRUE:
		case BN_FALSE:
			Set_Mark(LOWORD(wp)-1021, hwStatStr, hwAuto);// from resurse file constant
			break;
		case BN_STAT:
			LoadStatistic(hwAnswer, hwTrue, hwUnchecked, hwNext);
			break;
		}
		break;
	}
	return 0;
}
Example #11
0
 Stats<T> BivarStats<T>::estimateDeviation(const std::vector< std::pair<T, T> >& d) const
 {
    Stats<T> estats;
    size_t max( d.size() );
    for (size_t i=0; i<max; i++)
       estats.Add(std::abs(d[i].second - eval(d[i].first)));
    return estats;
 }
Example #12
0
void test_stats2() {
    // Test singleton pattern
    Stats* stats = Stats::getUniqueInstance();
    assert(stats->get((StatsKey)4) == 2);

    // Test clear()
    stats->clear();
    assert(stats->get((StatsKey)4) == 0);
}
Example #13
0
	void DoStatsUptime(CommandSource &source)
	{
		Stats *stats = Serialize::GetObject<Stats *>();
		time_t uptime = Anope::CurTime - Anope::StartTime;
		
		source.Reply(_("Current users: \002{0}\002 (\002{1}\002 ops)"), UserListByNick.size(), OperCount);
		source.Reply(_("Maximum users: \002{0}\002 ({1})"), stats->GetMaxUserCount(), Anope::strftime(stats->GetMaxUserTime(), source.GetAccount()));
		source.Reply(_("Services up \002{0}\002."), Anope::Duration(uptime, source.GetAccount()));
	}
Example #14
0
StereoCubemap* onNextCubemap(CubemapSource* source, StereoCubemap* cubemap)
{
    for (int i = 0; i < cubemap->getEye(0)->getFacesCount(); i++)
    {
        stats.store(StatsUtils::CubemapFace(i));
    }
	stats.store(StatsUtils::Cubemap());
    return cubemap;
}
Example #15
0
int main() {
    const int n {5};
    double data[n] {1.2, 2.3, 3.4, 4.5, 5.6};
    Stats stats;
    for (int i = 0; i < n; i++)
        stats.add(data[i]);
    std::cout << "average = " << stats.avg() << " for "
              << stats.n() << " data points" << std::endl;
    return 0;
}
Example #16
0
void verifyWalk(const IBSTuple &tuple, Stats &stat) {
    int32_t v = tuple.get<0>();
    SINVARIANT(v >= 0 && v < 10);
    SINVARIANT(!vw_seen[v]);
    SINVARIANT(tuple.get<1>() == ((v % 2) == 0));
    SINVARIANT(tuple.get<2>() == str(boost::format("%d") % (v * 10)));
    SINVARIANT(stat.count() == 1);
    SINVARIANT(stat.mean() == v*5);
    vw_seen[v] = true;
}
Example #17
0
void GrResourceCache::dumpStats(SkString* out) const {
    this->validate();

    int locked = fNonpurgeableResources.count();

    struct Stats {
        int fScratch;
        int fExternal;
        int fBorrowed;
        int fAdopted;
        size_t fUnbudgetedSize;

        Stats() : fScratch(0), fExternal(0), fBorrowed(0), fAdopted(0), fUnbudgetedSize(0) {}

        void update(GrGpuResource* resource) {
            if (resource->cacheAccess().isScratch()) {
                ++fScratch;
            }
            if (resource->cacheAccess().isExternal()) {
                ++fExternal;
            }
            if (resource->cacheAccess().isBorrowed()) {
                ++fBorrowed;
            }
            if (resource->cacheAccess().isAdopted()) {
                ++fAdopted;
            }
            if (!resource->resourcePriv().isBudgeted()) {
                fUnbudgetedSize += resource->gpuMemorySize();
            }
        }
    };

    Stats stats;

    for (int i = 0; i < fNonpurgeableResources.count(); ++i) {
        stats.update(fNonpurgeableResources[i]);
    }
    for (int i = 0; i < fPurgeableQueue.count(); ++i) {
        stats.update(fPurgeableQueue.at(i));
    }

    float countUtilization = (100.f * fBudgetedCount) / fMaxCount;
    float byteUtilization = (100.f * fBudgetedBytes) / fMaxBytes;

    out->appendf("Budget: %d items %d bytes\n", fMaxCount, (int)fMaxBytes);
    out->appendf("\t\tEntry Count: current %d"
                 " (%d budgeted, %d external(%d borrowed, %d adopted), %d locked, %d scratch %.2g%% full), high %d\n",
                 this->getResourceCount(), fBudgetedCount, stats.fExternal, stats.fBorrowed,
                 stats.fAdopted, locked, stats.fScratch, countUtilization, fHighWaterCount);
    out->appendf("\t\tEntry Bytes: current %d (budgeted %d, %.2g%% full, %d unbudgeted) high %d\n",
                 SkToInt(fBytes), SkToInt(fBudgetedBytes), byteUtilization,
                 SkToInt(stats.fUnbudgetedSize), SkToInt(fHighWaterBytes));
}
Example #18
0
void verifyZeroWalk(const IBSTuple &tuple, Stats &stat) {
    if (stat.count() == 1) {
	verifyWalk(tuple, stat);
    } else {
	SINVARIANT(stat.count() == 0);
	int32_t v = tuple.get<0>();
	SINVARIANT(v >= 0 && v < 10);
	SINVARIANT(tuple.get<1>() != ((v % 2) == 0) ||
		   tuple.get<2>() != str(boost::format("%d") % (v * 10)));
    }
}
Example #19
0
int runStatMultipliers (Stats stats, Stats multipliers) {
    int totalEffect = 0;
    Stats statEffects = mergeStatMaps(stats, multipliers);
    //Sum values in statEffects map
    Stats::const_iterator it;
    for (it = statEffects.begin(); it != statEffects.end(); it++) {
        totalEffect += (*it).second;
    }

    return totalEffect;
}
Example #20
0
void Stats::composeStats(const std::vector<std::string>& files)
{
	Stats* stats = new Stats(settings_benchmarks().output_file_xml, STATS_COLLECTION);
	for(std::vector<std::string>::const_iterator it = files.begin(); it != files.end(); ++it)
	{
		stats->addStat(*it);
	}
	delete stats;
	createStatsCompose(settings_benchmarks().output_dir.native() + "statsCompose.xsl");
	callComposeProcessor();
	fs::remove(fs::path(settings_benchmarks().output_dir.native() + "statsCompose.xsl"));
}
int main(int argc, char **argv){
  Stats a;
  ifstream inputfile;
  double mean;

  a.load(argv[1]);
  a.median(a);
  mean = a.mean();
  a.stndDev(mean);

return 0;
}
Example #22
0
Battle2::Tower::Tower(const Castle & castle, u8 twr, Arena & a) : Army::Troop(Monster::ARCHER), arena(a), type(twr), valid(true)
{
    count += castle.CountBuildings();
    count += castle.GetLevelMageGuild() - 1;

    if(count > 20) count = 20;
    if(TWR_CENTER != type) count /= 2;
    if(count == 0) count = 1;

    BattleInit();
    Stats* b = GetBattleStats();
    b->SetModes(CAP_TOWER);
}
Example #23
0
//Multiply elements of *identical* maps together
Stats mergeStatMaps(Stats mapA, Stats mapB) {
    Stats::const_iterator itA, itB;
    itB = mapB.begin();
    Stats result;

    for (itA = mapA.begin(); itA != mapA.end(); itA++) {
        //Take key from A, and multiply values from A and B.
        result.emplace((*itA).first, (*itA).second * (*itB).second );

        itB++;
    }
    return result;
};
Example #24
0
 void printCubeEntry(const lintel::StatsCube<Key>::MyAny &atuple, const Stats &val) {
     double bytes = val.mean() * val.countll();
     if (bytes < min_bytes) {
         return;
     }
     cout << format("%8s:%-5s %8s:%-5s %5s %d packets %.2f MiB\n") 
             % host32Str(atuple.data.get<0>(), atuple.any[0])
             % int32Str(atuple.data.get<1>(), atuple.any[1]) 
             % host32Str(atuple.data.get<2>(), atuple.any[2])
             % int32Str(atuple.data.get<3>(), atuple.any[3]) 
             % tuoStr(atuple.data.get<4>(), atuple.any[4])
             % val.countll() % (val.mean() * val.countll() / (1024.0*1024));
 }
Example #25
0
void writeStatsDebug(FILE* fdebug, const std::string& name, const Stats& stats)
{
	fprintf(fdebug, name.c_str());
	int pCount=0;
	for( Stats::const_iterator sit = stats.begin();
		sit != stats.end();
		++sit, ++pCount)
		fprintf(fdebug, "[%d] Ave=%4.2f:%4.2f:%4.2f:%4.2f::%4.2f:%4.2f, StDev=%4.2f:%4.2f:%4.2f:%4.2f::%4.2f:%4.2f\n", 
					pCount,
					sit->Ave[2], sit->Ave[3], sit->Ave[4], sit->Ave[5], sit->Ave[0], sit->Ave[1],
					sit->StDev[2], sit->StDev[3], sit->StDev[4], sit->StDev[5], sit->StDev[0], sit->StDev[1]
				);
}
Example #26
0
	bool TestCharacter::testEquipped()
	{
		Handle<Character> testChar(new Character());
		testChar->setName("TestChar");
		
		Stats *stats = testChar->getStats();
		stats->setBaseStat(Stat::STRENGTH, 10.0f);

		am_equalsDelta(10.0f, stats->getBaseStat(Stat::STRENGTH), 0.0001f);
		am_equalsDelta(10.0f, stats->getStat(Stat::STRENGTH), 0.0001f);

		BodyPart *part = new BodyPart("arm", BodyPartType::ARM);
		assert(testChar->addBodyPart(part));

		Handle<Item> sword(new Item());
		sword->getStatModifiers().addStatModifier(Stat::STRENGTH, StatModifier(5.0f, MOD_ADD));
		assert(testChar->equipItem(sword, "arm"));

		am_equalsDelta(10.0f, stats->getBaseStat(Stat::STRENGTH), 0.0001f);
		am_equalsDelta(15.0f, stats->getStat(Stat::STRENGTH), 0.0001f);

		assert(testChar->unequipItem("arm"));

		am_equalsDelta(10.0f, stats->getBaseStat(Stat::STRENGTH), 0.0001f);
		am_equalsDelta(10.0f, stats->getStat(Stat::STRENGTH), 0.0001f);

		return true;
	}
Example #27
0
	void OnUserConnect(User *u, bool &exempt) override
	{
		Stats *stats = GetStats();

		if (stats && UserListByNick.size() > stats->GetMaxUserCount())
		{
			stats->SetMaxUserCount(UserListByNick.size());
			stats->SetMaxUserTime(Anope::CurTime);

			Server *sserver = u->server;
			if (sserver && sserver->IsSynced())
				Log(this, "maxusers") << "connected - new maximum user count: " << UserListByNick.size();
		}
	}
Example #28
0
Stats allStats(int s) { //Generate stats all the same (0 for starting, 1 for player, etc)
Stats stats;

    //Physical
    stats.emplace("strength"  , s);
    stats.emplace("dexterity" , s);
    stats.emplace("endurance" , s);

    //Magical
    stats.emplace("power"     , s);
    stats.emplace("control"   , s);
    stats.emplace("stability" , s);
return stats;
};
Example #29
0
int main(int argc, char *argv[]) {
	int loops = 100, inner_loops = 100;
	int smin = 0, smax = 100000, sstep = 5000;
	int *values[] = { &loops, &smin, &smin, &smax, &smax, &sstep, &sstep };
	const char *identifier[] = { "-l", "-smin", "-rmin", "-smax", "-rmax",
			"-sstep", "-rstep" };
	handle_args(argc, argv, 7, values, identifier);

	printf("Loops: %d\n", loops);
	printf("Sizes: %d - %d, steps of %d\n", smin, smax, sstep);

	printf("Size;Expected Value;Standard deviation\n");
	for (int size = smin; size <= smax; size += sstep) {
		printf("%d", size);

		Stats stats;
		for (int l = 0; l < loops; l++) {
			int failures = 0;
			for (int il = 0; il < inner_loops; il++) {
				// init
				unsigned char a[size];
				for (int i = 0; i < size; i++)
					a[i] = 0;

				// run
				int flip = 0; // alternates between 0 (read) and 1 (write)
				int dummy;

				if (_xbegin() == _XBEGIN_STARTED) {
					for (int i = 0; i < size; i++) {
						if (flip)
							dummy = a[i]; // -O0!
						else
							a[i]++;

						flip ^= 1;
					}
					_xend();
				} else {
					failures++;
				}
			}
			float failure_rate = (float) failures * 100 / inner_loops;
			stats.addValue(failure_rate);
		}
		printf(";%.2f;%.2f\n", stats.getExpectedValue(),
				stats.getStandardDeviation());
	}
}
Example #30
0
int main(int argc, char** argv){
	Screen::Get().Init();

	move(0, 0);
	addstr("By: Vargeux");

	if(!has_colors()){
		mvprintw(
				Screen::Get().getH() / 2,
				Screen::Get().getW() / 2 - strlen("No color!") / 2,
				"No color!");
		return -1;
	}
	start_color();                          //Start color handling
	init_color(COLOR_WHITE, 500, 500, 500); //White will be gray
	init_pair(1, COLOR_WHITE, COLOR_BLUE);  //Regular window color

	refresh();                 //Swap buffers, print result
	getch();                   //Read key

	SocketServer::Get().Init();

	int window = 1;
	bool end = false;
	do{
		if(window == 0){
			//Exit
			end = true;
		}else if(window == 1){
			Login* login = new Login();
			login->loop() ? window++ : window--;
			delete login;
			Screen::Get().fillScreen(' ');
		}else if(window == 2){
			Stats* stats = new Stats();
			stats->loop() ? window++ : window--;
			delete stats;
			Screen::Get().fillScreen(' ');
		}else{
			end = true;
		}
	}while(!end);

	SocketServer::Get().Close();

	Screen::Get().Close();

	return 0;
}