double ExponentGenerator::Get() { double res = -1.0 / mLambda * log(1.0 - GetProbability()); if(!res) res = 1.0 / mLambda; return res; }
bool KITECH_MonteCarloLocalizationComp::Update(std::vector<double> sensorValue) { double *laserData = new double [sensorValue.size()+5]; double sum_prob = 0.; memcpy (laserData, &sensorValue[0], sizeof (double) * sensorValue.size()); for (int i = 0, n = particles.size(); i < n; ++i) { VirtualRobot &vr = particles[i]; double prob = (epsilon < vr.prob) ? GetProbability (vr, laserData) : epsilon; vr.prob *= prob; sum_prob += vr.prob; } if (epsilon < sum_prob) { for (int i = 0, n = particles.size(); i < n; ++i) { particles[i].prob /= sum_prob; } } else { for (int i = 0, n = particles.size(); i < n; ++i) { particles[i].prob = 1./n; } } Resampling (); if (particles.size () <= 0) { RandomizeAt (currentPosition.x, currentPosition.y, 2.5); } delete [] laserData; return false; }
TGraph* TDSPSingleEcho::Graph(TGraph *in, Double_t x1, Double_t x2, UInt_t num) { if (!in) in = new TGraph(); in->SetName(GetName()); in->SetTitle(GetTitle()); in->Set(num); if (x1==-9999) x1=fMinTau-fTauRange*.1; if (x2==-9999) x2=fMinTau+fTauRange*1.1; Double_t dx=(x2-x1)/num; for(register UInt_t i=0;i<num;++i) in->SetPoint(i,x1+dx,GetProbability(x1+dx)); return in; }
//--------------------------------------------------------------------------- //Ewensprobability = probability * num_of_combinations const std::string Test::GetEwensProbability() const { const BigInteger n_combinations = Newick::CalcNumOfCombinations( BinaryNewickVector(GetNewick()).Get()); try { const int i = n_combinations.toInt(); const double d = boost::numeric_cast<double>(i); const double ewens_probability = d * GetProbability(); return boost::lexical_cast<std::string>(ewens_probability); } catch (...) { const std::string s = bigIntegerToString(n_combinations) + std::string(" * ") + boost::lexical_cast<std::string>(GetProbability()); return s; } }
TGraph* TDSPMultiEcho::Graph(TGraph *in, Double_t x1, Double_t x2, UInt_t num) { if (!in) in = new TGraph(); in->SetName(GetName()); in->SetTitle(GetTitle()); in->Set(num); if (x1==-9999) x1=GetMinTau()-GetTauRange()*.1; if (x2==-9999) x2=GetMinTau()+GetTauRange()*1.1; Double_t dx=(x2-x1)/num; for(register UInt_t i=0;i<num;++i) { in->SetPoint(i,x1,GetProbability(x1)); x1+=dx; } return in; }
Kaadugal::VPFloat GetEntropy(void) { if(m_isAggregated == false) return 0.0; Kaadugal::VPFloat Entropy = 0.0; for(int i = 0; i < m_nClassesPerDim; ++i) { Kaadugal::VPFloat p = GetProbability(i); Entropy -= p == 0.0 ? 0.0 : (p * log(p) ) / log(2.0); } return Entropy; };
double PoissonGenerator::Get() { double num = -1; double log1, log2; log1 = 0; log2 = -mLambda; do { double p = GetProbability(); log1 += log(p); num++; }while(log1 >= log2); return num; }
void MixGaussian::MakeLookUpTable() { CvMat * SampleMat = cvCreateMat(3, 1, CV_64FC1); for(int R = 0; R < 256 ; R++) { printf("."); for(int G = 0; G < 256 ; G++) { for(int B = 0; B < 256 ; B++) { cvSetReal1D(SampleMat, 0, (double)R); cvSetReal1D(SampleMat, 1, (double)G); cvSetReal1D(SampleMat, 2, (double)B); _Probability[R][G][B] = GetProbability(SampleMat); } } } cvReleaseMat(&SampleMat); }
///////////////////////////////////////////////////////////////////////////// // Recursive helper function ///////////////////////////////////////////////////////////////////////////// void CJointBayesian::RecursiveJointBayesian(int player, int indexTotal) { if (player < 0) { double p = GetProbability(); for (int i = rs.GetPlayers(); --i >= 0;) dc.GetDistribution(i).Add(pindex[i], p); return; } int max = indexMax; if (max > indexTotal) max = indexTotal; int min = 0; if (min < indexTotal - player * indexMax) min = indexTotal - player * indexMax; for (pindex[player] = max + 1; --pindex[player] >= min;) RecursiveJointBayesian(player - 1, indexTotal - pindex[player]); }
double CauchyGenerator::Get() { double p = GetProbability(); return mLocation + mScale * tan(PI * (p - 0.5)); }
//************************** //This method is called to compute the solution ERMsg CLoganModel::OnExecuteAnnual() { _ASSERTE( m_weather.GetNbYear() >= 2); ERMsg msg; CAnnualStatVector stat(model.GetNbYear(), CTRef((short)model.GetYear(0)) ); // save result to disk for( int y=0; y<(int)model.GetNbYear(); y++) { //compute Cold Tolerance CMPBColdTolerance coldTolerance; coldTolerance.ComputeAnnual(weather); const CMPBCTResultVector& CT=coldTolerance.GetResult(); //*********************************** // fill accumulator CAccumulator accumulator(m_n); for(int y=0; y<weather.GetNbYear(); y++) { const CWeatherYear& weatherYear = weather[y]; CTPeriod p = weatherYear.GetGrowingSeason(); CAccumulatorData data; //Th = 42 F, Aug 1 to end of effective growing season if( p.End().GetMonth() >= AUGUST ) { p.Begin().SetJDay(FIRST_DAY); p.Begin().m_month = AUGUST; data.m_DDHatch = weatherYear.GetDD(5.56, p); //Th = 42 F, whole year data.m_DDGen = weatherYear.GetDD(5.56); } data.m_lowestMinimum = weatherYear.GetStat(STAT_TMIN, LOWEST); data.m_meanMaxAugust = weatherYear[AUGUST].GetStat(STAT_TMAX, MEAN); data.m_totalPrecip = weatherYear.GetStat(STAT_PRCP, SUM); //wather deficit was in mm CThornthwaitePET TPET(weatherYear, 0, CThornthwaitePET::POTENTIEL_STANDARD); data.m_waterDeficit = TPET.GetWaterDeficit(weatherYear)/25.4; //Water deficit, in inches data.m_precAMJ = 0; data.m_precAMJ += weatherYear[APRIL].GetStat(STAT_PRCP, SUM); data.m_precAMJ += weatherYear[MAY].GetStat(STAT_PRCP, SUM); data.m_precAMJ += weatherYear[JUNE].GetStat(STAT_PRCP, SUM); data.m_stabilityFlag = GetStabilityFlag(weatherYear); _ASSERTE( CT[y].m_year == weatherYear.GetYear()); //Skip the first year: No Cold Resistance data.m_S = (y>0)?CT[y].m_Psurv:1; accumulator.push_back(data); } accumulator.ComputeMeanP_Y1_Y2(); //*********************************** if( m_runLength<=0 || m_runLength>weather.GetNbYear()) m_runLength = weather.GetNbYear(); //skip the first year if m_runLength == weather.GetNbYear()-1 int s0 = max(1, m_runLength-1); m_firstYear = weather.GetFirstYear() + s0;//keep in memory the first year for(int i=0; i<NB_OUTPUT; i++) { //on doit changer le code si on veux utiliser la notion de runlength for(int y=s0; y<weather.GetNbYear(); y++) { m_F[i].push_back(GetProbability(accumulator, i, y, m_runLength) ); } } } SetOutput(stat); return msg; }
double ParetoGenerator::Get() { return mLocation / pow(GetProbability(), 1 / mAlpha); }