void DynProgProbLim::setLimits ( Int4 valueBegin_, // range for values is [valueBegin_, valueEnd_). Int4 valueEnd_) // range for values is [valueBegin_, valueEnd_). // assert (valueBegin_ < valueEnd_); { assert (valueBegin_ < valueEnd_); // take care of lost probability Int4 value = 0; for (value = getValueLower (); value < valueBegin_; value++) { d_probLost += getProb (value); } for (value = valueEnd_; value < getValueUpper (); value++) { d_probLost += getProb (value); } size_t arrayCapacity = static_cast <size_t> (valueEnd_ - valueBegin_); if (getArrayCapacity () <= arrayCapacity) { reserve (arrayCapacity); setValueBegin (valueBegin_); } else { setValueBegin (valueBegin_); reserve (arrayCapacity); } }
ExpandedKMer(const KMer k, const KMerStat &kmc) { for (unsigned i = 0; i < hammer::K; ++i) { s_[i] = k[i]; for (unsigned j = 0; j < 4; ++j) lprobs_[4*i + j] = ((char)j != s_[i] ? getRevProb(kmc, i, /* log */ true) - log(3) : getProb(kmc, i, /* log */ true)); } count_ = kmc.count; }
double Gibbs_ask(int N) { int bn[] = {0, 1, 1, 1}; int n = 0; int j; for (j = 0; j < N; ++j) { int z = rand() % 2; bn[z] = sampling(getProb(z, bn)); if (bn[1]) ++n; } return (n + 0.0) / N; }
// E-step void computeProbabilities(prob_matrix_t& prob, std::vector<double>& sums, const dataPoints_t& X, const estimates_t& estimate) { std::vector<double>& psums = prob.back(); std::fill(psums.begin(), psums.end(), 0); prob_matrix_t::iterator probItr = prob.begin(); for(estimates_t::const_iterator estimateItr = estimate.begin(); estimateItr != estimate.end(); ++estimateItr, ++probItr) { std::transform(X.begin(), X.end(), probItr->begin(), getProb(*estimateItr)); std::transform(probItr->begin(), probItr->end(), psums.begin(), psums.begin(), std::plus<double>()); } probItr = prob.begin(); for(unsigned int dist = 0; dist < estimate.size(); ++dist, ++probItr) { std::transform(probItr->begin(), probItr->end(), psums.begin(), probItr->begin(), std::divides<double>()); sums[dist] = std::accumulate(probItr->begin(), probItr->end(), 0.0); } }
void Ray::makeTables(){ double x1 = 0; double x2 = 0.5; int i=rtail; int j=i; for(;j>0;i++,j--){ double p = getProb(x1,x2); coordVec[j]=-floor(x2); coordVec[i]=floor(x2); probVec[i]+=p; probVec[j]+=p; x1 = x2; x2 = x1+1.0; } double ptail = 1.0-cdf(xsigma); coordVec[0] = ltail; coordVec[vlen-1] = rtail; probVec[0]=ptail; probVec[vlen-1]=ptail; makeAliasTable(); }
void MainWindow::timerEvent(QTimerEvent*) { mate.moveToNextFrame(); mate.act(); move(pos() + mate.movement()); if(geometry().bottom() > screenRect.bottom()) { QRect newGeometry = geometry(); newGeometry.moveBottom(screenRect.bottom()); setGeometry(newGeometry); mate.meetGround(); } else if(!mate.isCaptured() && geometry().bottom() < screenRect.bottom()) { mate.startFalling(); } if(getProb(PORTAL_PROB)) { move(getRandomPos(screenRect, Mate::spriteSize())); mate.startFalling(); } update(); }
double getProb(const arma::vec & datum) const { return getProb(datum, 0, (unsigned int)mixture_.size()); }
double getProb(const arma::vec & datum, unsigned int index) const { return getProb(datum, index, index + 1); }