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


C++ Gaussian::init_mu_sigma方法代码示例

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


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

示例1: adjust_players

void TrueSkill::adjust_players(std::vector<Player*> players) {
    Constants constants;

    std::sort(players.begin(), players.end(), player_sorter());

    std::vector<Variable*> ss, ps, ts, ds;
    unsigned int i = 0, size = players.size();
    double gammasqr = constants.GAMMA * constants.GAMMA,
           betasqr = constants.BETA * constants.BETA;

    for (i = 0; i < size; ++i) {
        ss.push_back(new Variable());
        ps.push_back(new Variable());
        ts.push_back(new Variable());
    }

    for (i = 0; i < size - 1; ++i) {
        ds.push_back(new Variable());
    }

    std::vector<PriorFactor*> skill;
    for (i = 0; i < size; ++i) {
        Player* pl = players[i];
        Variable* s = ss[i];
        Gaussian* gaussian = new Gaussian();
        gaussian->init_mu_sigma(pl->mu, sqrt((pl->sigma * pl->sigma) + gammasqr));
        skill.push_back(new PriorFactor(s, gaussian));
    }

    std::vector<LikelihoodFactor*> skill_to_perf;
    for (i = 0; i < size; ++i) {
        Variable* s = ss[i];
        Variable* p = ps[i];
        skill_to_perf.push_back(new LikelihoodFactor(s, p, betasqr));
    }

    std::vector<SumFactor*> perf_to_team;
    for (i = 0; i < size; ++i) {
        std::vector<Variable*>* p = new std::vector<Variable*>();
        std::vector<double>* c = new std::vector<double>;
        p->push_back(ps[i]);
        c->push_back(1.0);
        perf_to_team.push_back(new SumFactor(ts[i], p, c));
    }

    std::vector<SumFactor*> team_diff;
    for (i = 0; i < size - 1; ++i) {
        std::vector<Variable*>* p = new std::vector<Variable*>();
        p->push_back(ts[i]);
        p->push_back(ts[i + 1]);
        std::vector<double>* c = new std::vector<double>;
        c->push_back(1.0);
        c->push_back(-1.0);
        team_diff.push_back(new SumFactor(ds[i], p, c));
    }

    std::vector<TruncateFactor*> trunc;
    for (i = 0; i < size - 1; ++i) {
        TruncateFactor* tf;
        if (players[i]->rank == players[i + 1]->rank) {
            tf = new TruncateFactorDraw(ds[i], constants.EPSILON);
        } else {
            tf = new TruncateFactorWin(ds[i], constants.EPSILON);
        }
        trunc.push_back(tf);
    }

    for(std::vector<PriorFactor*>::iterator it = skill.begin(); it != skill.end(); ++it) {
        (*it)->start();
    }

    for(std::vector<LikelihoodFactor*>::iterator it = skill_to_perf.begin(); it != skill_to_perf.end(); ++it) {
        (*it)->update_value();
    }

    for(std::vector<SumFactor*>::iterator it = perf_to_team.begin(); it != perf_to_team.end(); ++it) {
        (*it)->update_sum();
    }

    for (i = 0; i < 5; ++i) {
        for(std::vector<SumFactor*>::iterator it = team_diff.begin(); it != team_diff.end(); ++it) {
            (*it)->update_sum();
        }

        for(std::vector<TruncateFactor*>::iterator it = trunc.begin(); it != trunc.end(); ++it) {
            (*it)->update();
        }

        for(std::vector<SumFactor*>::iterator it = team_diff.begin(); it != team_diff.end(); ++it) {
            (*it)->update_term(0);
            (*it)->update_term(1);
        }
    }

    for(std::vector<SumFactor*>::iterator it = perf_to_team.begin(); it != perf_to_team.end(); ++it) {
        (*it)->update_term(0);
    }

    for(std::vector<LikelihoodFactor*>::iterator it = skill_to_perf.begin(); it != skill_to_perf.end(); ++it) {
        (*it)->update_mean();
//.........这里部分代码省略.........
开发者ID:JesseBuesking,项目名称:trueskill,代码行数:101,代码来源:trueskill.cpp


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