本文整理汇总了C++中tree::bn方法的典型用法代码示例。如果您正苦于以下问题:C++ tree::bn方法的具体用法?C++ tree::bn怎么用?C++ tree::bn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tree
的用法示例。
在下文中一共展示了tree::bn方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getsuff
//--------------------------------------------------
//get sufficient stats for pair of bottom children nl(left) and nr(right) in tree x
void getsuff(std::vector<std::vector<double> >& X,
tree& x, tree::tree_cp nl, tree::tree_cp nr,
xinfo& xi, dinfo& di, sinfo& sl, sinfo& sr)
{
double* xx = new double[di.n_cov];
double y; //current y
sl.n=0;sl.sy=0.0;sl.sy2=0.0;
sr.n=0;sr.sy=0.0;sr.sy2=0.0;
for(size_t i=0;i<di.n_samp;i++) {
for(size_t j=0;j<di.n_cov; j++){
xx[j] = X[i][j];
}
tree::tree_cp bn = x.bn(xx,xi);
if(bn==nl) {
y = di.y[i];
sl.n++;
sl.sy += y;
sl.sy2 += y*y;
}
if(bn==nr) {
y = di.y[i];
sr.n++;
sr.sy += y;
sr.sy2 += y*y;
}
}
}
示例2: allsuff
//--------------------------------------------------
//get sufficients stats for all bottom nodes
void allsuff(std::vector<std::vector<double> >& X,
tree& x, xinfo& xi, dinfo& di, tree::npv& bnv,
std::vector<sinfo>& sv)
{
tree::tree_cp tbn; //the pointer to the bottom node for the current observations
size_t ni; //the index into vector of the current bottom node
double* xx = new double[di.n_cov];
double y; //current y
bnv.clear();
x.getbots(bnv);
typedef tree::npv::size_type bvsz;
bvsz nb = bnv.size();
sv.resize(nb);
std::map<tree::tree_cp,size_t> bnmap;
for(bvsz i=0;i!=bnv.size();i++) bnmap[bnv[i]]=i;
for(size_t i=0;i<di.n_samp;i++) {
for(size_t j=0;j<di.n_cov; j++){
xx[j] = X[i][j];
}
y=di.y[i];
tbn = x.bn(xx,xi);
ni = bnmap[tbn];
++(sv[ni].n);
sv[ni].sy += y;
sv[ni].sy2 += y*y;
}
}
示例3: fit
void fit(tree& t, std::vector<std::vector<double> >& X, dinfo di, xinfo& xi, std::vector<double>& fv)
{
double* xx = new double[di.n_cov];
tree::tree_cp bn;
for(size_t i=0;i<di.n_samp;i++) {
for(size_t j=0;j<di.n_cov; j++){
xx[j] = X[i][j];
}
bn = t.bn(xx,xi);
fv[i] = bn->getm();
}
}