⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 medianpartitioner.cpp

📁 dysii is a C++ library for distributed probabilistic inference and learning in large-scale dynamical
💻 CPP
字号:
#include "MedianPartitioner.hpp"using namespace indii::ml::aux;MedianPartitioner::~MedianPartitioner() {  //}bool MedianPartitioner::init(DiracMixturePdf* p,      const std::vector<unsigned int>& is) {  /* pre-condition */  assert (is.size() >= 2);  unsigned int i, j;  vector lower(p->get(is[0]));  vector upper(p->get(is[0]));  vector length(p->getDimensions());    /* calculate bounds */  for (i = 1; i < is.size(); i++) {    for (j = 0; j < p->getDimensions(); j++) {      vector& x = p->get(is[i]);      if (x(j) < lower(j)) {        lower(j) = x(j);      } else if (x(j) > upper(j)) {        upper(j) = x(j);      }    }  }  /* select longest dimension */  noalias(length) = upper - lower;  this->index = index_norm_inf(length);     /* split on median of this dimension */  std::vector<double> projection(is.size());  unsigned int median = projection.size() / 2;  for (i = 0; i < is.size(); i++) {    projection[i] = p->get(is[i])(this->index);  }  std::nth_element(projection.begin(), projection.begin() + median,      projection.end());  this->value = projection[median];  return length(this->index) > 0.0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -