コード例 #1
0
ファイル: Gaussian.cpp プロジェクト: cskarby/gridpp
double CalibratorGaussian::my_f(const gsl_vector *v, void *params) {
   double x, y;
   double *p = (double *)params;

   int N = p[0];
   double* obs = p + 1;
   double* mean = p + 1 + N;
   double* spread = p + 1 + 2*N;

   const double* arr = gsl_vector_const_ptr(v, 0);
   std::vector<float> vec(arr, arr+mNumParameters);
   Parameters par(vec);
   float sa  = gsl_vector_get(v, 0);
   float sb  = gsl_vector_get(v, 1);

   float total = 0;
   for(int n = 0; n < N; n++) {
      float pdf = getPdf(obs[n], mean[n], spread[n], par);
      // std::cout << "   " << obs[n] << " " << mean[n] << std::endl;
      if(pdf == 0 || !Util::isValid(pdf))
         pdf = 0.00001;
      assert(pdf > 0);
      total += log(pdf);
   }
   // std::cout << "Log likelihood: " << total << std::endl;
   return -total; 
}
コード例 #2
0
ファイル: Continuous.cpp プロジェクト: WFRT/Comps
float Continuous::getMomentCore(int iMoment, const Ensemble& iEnsemble, const Parameters& iParameters) const {
   // TODO: Not tested
   const Variable* var = Variable::get(iEnsemble.getVariable());

   float total = 0;

   float minX  = var->getMin();
   float maxX  = var->getMax();
   int   nX    = 1000;
   float dX    = (maxX - minX)/((float) nX);

   float c = 0;
   if(iMoment > 1) {
      // Compute center of moment
      c = getMoment(1, iEnsemble, iParameters);
   }

   for(int i = 0; i < nX; i++) {
      float x = minX + i*dX;
      float pdf = getPdf(x, iEnsemble, iParameters);
      if(!Global::isValid(pdf))
         return Global::MV;

      total += pow(x - c, iMoment) * pdf;
   }
   return total * dX;
}
コード例 #3
0
void XEMBinaryParameter::getAllPdf(double** tabFik,double* tabProportion)const{
  int64_t nbSample = _model->getNbSample();
  int64_t i;
  int64_t k;

  for(i=0 ; i<nbSample ; i++){
    for(k=0 ; k<_nbCluster ; k++){
      tabFik[i][k] = getPdf(i,k) * tabProportion[k];
    }
  }
}
コード例 #4
0
ファイル: GammaComboEngine.cpp プロジェクト: po10/gammacombo
///
/// Add a new Combiner, consisting of the specified PDFs.
/// The pdf arguments refer to the GammaComboEngine ID of the PDFs
/// that should be combined. Add them before using addPdf().
/// Also an empty combiner is possible, that has no PDFs, so it can be filled
/// later. In that case, leave all pdf arguments at -1.
///
void GammaComboEngine::newCombiner(int id, TString name, TString title,
                                   int pdf1, int pdf2, int pdf3, int pdf4, int pdf5,
                                   int pdf6, int pdf7, int pdf8, int pdf9, int pdf10,
                                   int pdf11, int pdf12, int pdf13, int pdf14, int pdf15)
{
    if ( combinerExists(id) ) {
        cout << "GammaComboEngine::newCombiner() : ERROR : Requested new Combiner id exists already in GammaComboEngine. Exit." << endl;
        exit(1);
    }
    Combiner *c = new Combiner(arg, name, title);
    if ( pdf1 >-1 ) c->addPdf(getPdf(pdf1 ));
    if ( pdf2 >-1 ) c->addPdf(getPdf(pdf2 ));
    if ( pdf3 >-1 ) c->addPdf(getPdf(pdf3 ));
    if ( pdf4 >-1 ) c->addPdf(getPdf(pdf4 ));
    if ( pdf5 >-1 ) c->addPdf(getPdf(pdf5 ));
    if ( pdf6 >-1 ) c->addPdf(getPdf(pdf6 ));
    if ( pdf7 >-1 ) c->addPdf(getPdf(pdf7 ));
    if ( pdf8 >-1 ) c->addPdf(getPdf(pdf8 ));
    if ( pdf9 >-1 ) c->addPdf(getPdf(pdf9 ));
    if ( pdf10>-1 ) c->addPdf(getPdf(pdf10));
    if ( pdf11>-1 ) c->addPdf(getPdf(pdf11));
    if ( pdf12>-1 ) c->addPdf(getPdf(pdf12));
    if ( pdf13>-1 ) c->addPdf(getPdf(pdf13));
    if ( pdf14>-1 ) c->addPdf(getPdf(pdf14));
    if ( pdf15>-1 ) c->addPdf(getPdf(pdf15));
    addCombiner(id, c);
}
コード例 #5
0
ファイル: GammaComboEngine.cpp プロジェクト: po10/gammacombo
PDF_Abs* GammaComboEngine::operator[](int idx)
{
    return getPdf(idx);
}