本文整理汇总了C++中Distribution类的典型用法代码示例。如果您正苦于以下问题:C++ Distribution类的具体用法?C++ Distribution怎么用?C++ Distribution使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Distribution类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: apart
void CCMSDIntegrator::ParseCMSD(std::string filename)
{
CMSD::CCMSD doc = CMSD::CCMSD::LoadFromFile(filename);
doc.SaveToFile((::ExeDirectory() + "Test1.xml").c_str(), true);
//CMSD::CCMSD::DataSection d = doc.DataSection().first();
CMSD::CwhiteSpaceType root = doc.whiteSpace.first();
CMSD::CCMSDDocument cmsddocument = doc.CMSDDocument[0];
CMSD::CDataSectionType2 data = cmsddocument.DataSection[0];
for(int i=0; i< data.PartType.count() ; i++)
{
Part * apart ( (Part*) Part().CreateSave<Part>());
apart->Load(data.PartType[i].GetNode());
//std::vector<IObjectPtr> &someparts ( apart->objects());
//Part * part2=(Part *) someparts[0].get();
}
for(int i=0; i< data.ProcessPlan.count() ; i++)
{
ProcessPlan * aplan ( (ProcessPlan *) IObject::CreateSave<ProcessPlan>());
aplan->Load(data.ProcessPlan[i].GetNode());
}
for(int i=0; i< data.Resource.count() ; i++)
{
if(Cell::IsResourceCell(data.Resource[i].GetNode()))
{
Cell * acell( (Cell *) IObject::CreateSave<Cell>());
acell->Load(data.Resource[i].GetNode());
}
else
{
Resource * aresource ((Resource *) IObject::CreateSave<Resource>());
aresource->Load(data.Resource[i].GetNode());
}
}
for(int i=0; i< data.Job.count() ; i++)
{
Job * ajob ( IObject::CreateSave<Job>() );
ajob->Load(data.Job[i].GetNode());
}
for(int i=0; i< data.DistributionDefinition.count() ; i++)
{
Distribution * astat ( (Distribution *) IObject::CreateSave<Distribution>() );
astat->LoadDefinition(data.DistributionDefinition[i].GetNode());
}
for(int i=0; i< data.Calendar.count() ; i++)
{
Calendar * calendar ( (Calendar *) IObject::CreateSave<Calendar>());
calendar->Load(data.Calendar[i].GetNode());
}
for(int i=0; i< data.Layout.count() ; i++)
{
Layout * layout ((Layout *) IObject::CreateSave<Layout>());
layout->Load(data.Layout[i].GetNode());
}
//CMSD::CInventoryItem inv = data.InventoryItem[0];
//inv.Location
int j=0;
}
示例2: combine
Distribution combine(Distribution const& c, InfoMap const& info)
{
std::map<Cell, Value> tmp;
for (size_t i = 0; i < c.size(); ++i)
{
Distribution const& w = info(c.at(i).first)->weights;
Value const f = c.at(i).second;
for (size_t j = 0; j < w.size(); ++j)
{
Cell const v = w.at(j).first;
if (tmp.count(v) == 0)
tmp[v] = 0;
tmp[v] += f * w.at(j).second;
}
}
Distribution result(tmp.size());
std::map<Cell, Value>::const_iterator iter = tmp.begin();
for (size_t i = 0; i < tmp.size(); ++i, ++iter)
result[i] = std::make_pair(iter->first, iter->second);
return result;
}
示例3: CREATEIF
void Resource::Save(CMSD::CResource& resource)
{
resource.Identifier.append() = std::string((LPCSTR) identifier);
CREATEIF(resource.Name.append() , name);
CREATEIF(resource.ResourceType.append() , type);
CREATEIF(resource.Description.append(), description);
//PropertyElement(L"Capacity", capacity).Save(resource.Property.append());
//PropertyElement(L"Manufacturer", manufacturer).Save(resource.Property.append());
//PropertyElement(L"Serial_number", serial_number).Save(resource.Property.append());
//for(int i=0; i< simpleproperties.size(); i++)
//{
// simpleproperties[i].Save(resource.Property.append());
//}
PropertyElement().SaveProperties<CMSD::CResource>(resource, properties);
Distribution* mtbfdist = CCMSDIntegrator::FindDistributionById(mtbfid);
Distribution* mttrdist = CCMSDIntegrator::FindDistributionById(mttrid);
if(mtbfdist!=NULL)// !mtbf.IsEmpty())
mtbf->Save(resource.Property.append());
if(mttrdist!=NULL)
mttrdist->Save(resource.Property.append());
}
示例4: ColorizeByQuality
void ColorizeByQuality(uintptr_t meshptr, bool vertexQuality, float qMin, float qMax, float perc, bool zerosym, int colorMap)
{
MyMesh &m = *((MyMesh*) meshptr);
bool usePerc = (perc > 0);
Distribution<float> H;
if(vertexQuality)
tri::Stat<MyMesh>::ComputePerVertexQualityDistribution(m, H);
else
tri::Stat<MyMesh>::ComputePerFaceQualityDistribution(m, H);
float percLo = H.Percentile(perc/100.0f);
float percHi = H.Percentile(1.0f - (perc/100.0f));
if (qMin == qMax) {
std::pair<float, float> minmax;
if(vertexQuality)
minmax = tri::Stat<MyMesh>::ComputePerVertexQualityMinMax(m);
else
minmax = tri::Stat<MyMesh>::ComputePerFaceQualityMinMax(m);
qMin = minmax.first;
qMax = minmax.second;
}
if (zerosym) {
qMin = std::min(qMin, -math::Abs(qMax));
qMax = -qMin;
percLo = std::min(percLo, -math::Abs(percHi));
percHi = -percLo;
}
if (usePerc) {
qMin = percLo;
qMax = percHi;
printf("Used (%f %f) percentile (%f %f)\n", percLo, percHi, perc, (100.0f-perc));
}
printf("Quality Range: %f %f; Used (%f %f)\n", H.Min(), H.Max(), qMin, qMax);
switch (colorMap)
{
case 0: if(vertexQuality)
tri::UpdateColor<MyMesh>::PerVertexQualityRamp(m, qMin, qMax);
else
tri::UpdateColor<MyMesh>::PerFaceQualityRamp(m, qMin, qMax);
break;
case 1: if(vertexQuality)
tri::UpdateColor<MyMesh>::PerVertexQualityGray(m, qMin, qMax);
else
tri::UpdateColor<MyMesh>::PerFaceQualityGray(m, qMin, qMax);
break;
case 2: if(vertexQuality)
tri::UpdateColor<MyMesh>::PerVertexQualityRamp(m, qMin, qMax);
else
tri::UpdateColor<MyMesh>::PerFaceQualityRamp(m, qMin, qMax);
break;
default: assert(0);
}
}
示例5: setByDistribution
//Set the app by the current distro
void GeneralModule::setByDistribution()
{
Distribution dist;
distroLogoButton->setIcon(QIcon(":/resources/distributions/" + dist.name().toLower() + "-icon.png").pixmap(128, 128));
distroNameLabel->setText("<h1>" + dist.name() + "</h1>" + " " + dist.version() + " " + dist.codename());
kernelLabel->setText("<b>" + trUtf8("Linux Kernel") + "</b> " + dist.kernel());
}
示例6: switch
void Calculator::generate_sample(params & par, std::vector<double> &rez) {
switch(par.distr) {
case NORMAL:
Distribution< boost::normal_distribution<>, double > dis;
dis.generate_sample(par.n, rez);
break;
}
}
示例7: print
void print(Distribution values){
for (Distribution::iterator it=values.begin();it!=values.end();it++){
cout << "(" << it->first.first << "," << it->first.second << "):" << endl;
cout << "vector1:" << endl;
int size1 = it->second.first.size();
for (int i=0;i<size1;i++){cout << it->second.first[i] << endl;}
cout << "vector2:" << endl;
int size2 = it->second.second.size();
for (int i=0;i<size2;i++){cout << it->second.second[i] << endl;}
}
}
示例8: distribution
Distribution* CCMSDIntegrator::FindDistributionById(bstr_t id)
{
Distribution * dist = IObject::Create<Distribution>() ;
for(int i=0; i< dist->objects().size(); i++)
{
Distribution* distribution ( (Distribution *) dist->objects()[i].get());
if(distribution->identifier==id)
return distribution;
}
return NULL;
}
示例9: StatTest
void StatTest()
{
Distribution stat, stat2,stat3,stat4;
stat.SetParameters(_T("normal"), 10, 5);
stat2.SetParameters(_T("uniform"), 5, 10);
stat3.SetParameters(_T("exponential"), 5, 10,18);
stat4.SetParameters(_T("weibull"),1,5); // gamma, k
std::vector<double> normdata,unidata,expdata,weibdata;
for(int i=0; i< 10000; i++)
{
normdata.push_back(stat.RandomVariable());
unidata.push_back(stat2.RandomVariable());
expdata.push_back(stat3.RandomVariable());
weibdata.push_back(stat4.RandomVariable());
}
std::string results;
StatFitting statfit;
statfit.EstimateAll(normdata);
results=statfit.ToString();
OutputDebugString(results.c_str());
StatFitting statfit1;
statfit1.EstimateAll(unidata);
results=statfit1.ToString();
OutputDebugString(results.c_str());
StatFitting statfit2;
statfit2.EstimateAll(expdata);
OutputDebugString(statfit2.ToString().c_str());
StatFitting statfitW;
double a,b;
std::vector<double> T = TokenList<double>("16,34,53,75,93,120", ","); // vlist_of<double>( 16 )( 34)( 53)( 75)( 93)( 120 );
statfitW.ComputeWeibull( T, a, b);
//http://home.comcast.net/~pstlarry/BaikoMan.htm
StatFitting statfit3;
//std::vector<double> weibulldata = data.GetData("D:\\Program Files\\NIST\\proj\\DES\\SimulationModel\\CapacityCalculator\\Data\\WeibullTestDat1.txt");
//statfit3.EstimateAll(weibdata);
Distribution dist = statfit3.BestFit(weibdata);
OutputDebugString(dist.ToString().c_str());
}
示例10: splitCritValue
double InfoGainSplitCrit::splitCritValue(Distribution &bags, double totalNoInst, double oldEnt) const {
double numerator, noUnknown, unknownRate;
noUnknown = totalNoInst - bags.total();
unknownRate = noUnknown / totalNoInst;
numerator = (oldEnt - newEnt(bags));
numerator = (1 - unknownRate) * numerator;
// Splits with no gain are useless.
if (Utils::eq(numerator, 0)) {
return 0;
}
return numerator / bags.total();
}
示例11: operator
double NV_EM_log_likelihood::operator()( const Matrix& data,
const ProbTable& theta,
const Distribution& pY,
const CondProbTable& pXY ) const {
double result = 0.0;
unsigned N = utility::nrows(data);
for ( unsigned i = 0; i < N; ++i ) {
const std::vector<int>& X = data[i];
unsigned K = pY.size(), P = X.size();
for ( unsigned y = 0; y < K; ++y ) {
double llh_y = m_log(pY[y]);
for ( int p = 0; p < P; ++p ) {
int x = X[p];
if (pXY[y][p][x]) {
llh_y += m_log( pXY[y][p][x] );
}
}
llh_y *= theta[i][y];
result += llh_y;
}
}
// printf("result: %f\n", result );
return result;
}
示例12: transition
HMM<Distribution>::HMM(const size_t states,
const Distribution emissions,
const double tolerance) :
transition(arma::ones<arma::mat>(states, states) / (double) states),
emission(states, /* default distribution */ emissions),
dimensionality(emissions.Dimensionality()),
tolerance(tolerance)
{ /* nothing to do */ }
示例13: ClampVertexQuality
void ClampVertexQuality(uintptr_t meshptr, float qMin, float qMax, float perc, bool zerosym)
{
MyMesh &m = *((MyMesh*) meshptr);
bool usePerc = (perc > 0);
Distribution<float> H;
tri::Stat<MyMesh>::ComputePerVertexQualityDistribution(m, H);
float percLo = H.Percentile(perc/100.0f);
float percHi = H.Percentile(1.0f - (perc/100.0f));
if (qMin == qMax) {
std::pair<float, float> minmax = tri::Stat<MyMesh>::ComputePerVertexQualityMinMax(m);
qMin = minmax.first;
qMax = minmax.second;
}
if (zerosym) {
qMin = std::min(qMin, -math::Abs(qMax));
qMax = -qMin;
percLo = std::min(percLo, -math::Abs(percHi));
percHi = -percLo;
}
if (usePerc) {
tri::UpdateQuality<MyMesh>::VertexClamp(m, percLo, percHi);
printf("Quality Range: %f %f; Used (%f %f) percentile (%f %f)\n", H.Min(), H.Max(), percLo, percHi, perc, (100.0f-perc));
} else {
tri::UpdateQuality<MyMesh>::VertexClamp(m, qMin, qMax);
printf("Quality Range: %f %f; Used (%f %f)\n", H.Min(), H.Max(), qMin, qMax);
}
}
示例14: getOptions
SUMOReal
NIVissimDistrictConnection::getRealSpeed(/*NBDistribution &dc, */int distNo) const {
std::string id = toString<int>(distNo);
Distribution* dist = NBDistribution::dictionary("speed", id);
if (dist == 0) {
WRITE_WARNING("The referenced speed distribution '" + id + "' is not known.");
WRITE_WARNING(". Using default.");
return OptionsCont::getOptions().getFloat("vissim.default-speed");
}
assert(dist != 0);
SUMOReal speed = dist->getMax();
if (speed < 0 || speed > 1000) {
WRITE_WARNING(" False speed at district '" + id);
WRITE_WARNING(". Using default.");
speed = OptionsCont::getOptions().getFloat("vissim.default-speed");
}
return speed;
}
示例15: fill_matrix
void fill_matrix(int rank, Distribution &ds, Distribution &block_ds) {
// set B columns
int n_cols_B=block_ds.size();
std::vector<PetscInt> b_cols(n_cols_B);
for( unsigned int p=0;p<block_ds.np();p++)
for (unsigned int j=block_ds.begin(p); j<block_ds.end(p); j++) {
//int proc=block_ds.get_proc(j);
b_cols[j]=ds.end(p)+j;
}
// create block A of matrix
int local_idx=0;
for (unsigned int i = block_ds.begin(); i < block_ds.end(); i++) {
// make random block values
std::vector<PetscScalar> a_vals(block_size * block_size, 0);
for (unsigned int j=0; j<block_size; j++)
a_vals[ j + j*block_size ]= (rank + 2);
// set rows and columns indices
std::vector<PetscInt> a_rows(block_size);
for (unsigned int j=0; j<block_size; j++) {
a_rows[j]=ds.begin() + block_ds.begin() + local_idx;
local_idx++;
}
mat_set_values(block_size, &a_rows[0], block_size, &a_rows[0], &a_vals[0]);
// set B values
std::vector<PetscScalar> b_vals(block_size*n_cols_B);
for (int j=0; j<block_size*n_cols_B; j++)
b_vals[j] = 1;
// set C values
std::vector<PetscScalar> c_vals(n_cols_B);
for (int j=0; j<n_cols_B; j++)
c_vals[j] = 0;
// must iterate per rows to get correct transpose
for(unsigned int row=0; row<block_size;row++) {
mat_set_values(1, &a_rows[row], 1, &b_cols[rank], &b_vals[row*n_cols_B]);
mat_set_values(1, &b_cols[rank],1, &a_rows[row], &b_vals[row*n_cols_B]);
}
mat_set_values(1, &b_cols[rank], 1, &b_cols[rank], &c_vals[rank]);
}
}