当前位置: 首页>>代码示例>>C++>>正文


C++ Chain::compute_partialJointPosteriorDensity_overSubLoci方法代码示例

本文整理汇总了C++中Chain::compute_partialJointPosteriorDensity_overSubLoci方法的典型用法代码示例。如果您正苦于以下问题:C++ Chain::compute_partialJointPosteriorDensity_overSubLoci方法的具体用法?C++ Chain::compute_partialJointPosteriorDensity_overSubLoci怎么用?C++ Chain::compute_partialJointPosteriorDensity_overSubLoci使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Chain的用法示例。


在下文中一共展示了Chain::compute_partialJointPosteriorDensity_overSubLoci方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: computeLogJointDensity_MPI_overSubLoci

// 1/4/2016
// 'demographicPara' is a 1x6 matrix.
long double MaxPosterior::computeLogJointDensity_MPI_overSubLoci(Eigen::MatrixXd demographicPara, IM im, popTree* poptree, Chain coldCh, unsigned int nProcs, unsigned int crr_procID)
{
  // std::cout <<"In computeLogJointDensity_MPI_overSubLoci()\n";

  poptree->replacePara(demographicPara);

  coldCh.compute_partialJointPosteriorDensity_overSubLoci(poptree, im, crr_procID, nProcs);
  std::vector<long double> logExpectationOfEachCoalProb = coldCh.get_logExpectationOfCoalProb();
  unsigned int numSubLoci = coldCh.getNumSubLoci();

  // std::cout <<"numSubLoci ="<<numSubLoci <<"\n";

  long double posterior = 1;
  if(numSubLoci != logExpectationOfEachCoalProb.size())
    {
      std::cout << "** Error In MaxPosterior::computeJointDensity_MPI_overSubSample() **\n";
      std::cout << "numSubLoci = " << numSubLoci 
		<< " expectationOfEachCoalProb.size() = " << logExpectationOfEachCoalProb.size() <<"\n\n";
    }
  long double local_logPosterior_subLoci =0;
  long double global_logPosterior = 0;
  for(unsigned int lc=0; lc< numSubLoci; lc++)
    {
      local_logPosterior_subLoci += logExpectationOfEachCoalProb.at(lc);
    }
  
  MPI::COMM_WORLD.Barrier();
  MPI::COMM_WORLD.Allreduce(&local_logPosterior_subLoci, &global_logPosterior, 1, MPI_LONG_DOUBLE, MPI_SUM);
  MPI::COMM_WORLD.Barrier();
  
  long double logPosterior = 0;
  if(crr_procID ==0)
    {	
      Eigen::Vector3d paraMax = im.get_paraMax();
      double priorPopTree = poptree->computeJointPrior(paraMax);
      //posterior = exp(global_logPosterior+log(priorPopTree));
      logPosterior = global_logPosterior; //  +log(priorPopTree);
      // std::cout <<"log(priorPopTree) = " << log(priorPopTree) <<"\n";
    }
  
 
  
  // std::cout << "crr_procID=" << crr_procID << " logPosterior = " << logPosterior <<"\n";    
  return logPosterior;
}
开发者ID:yujin-chung,项目名称:MIST,代码行数:47,代码来源:optimization.cpp


注:本文中的Chain::compute_partialJointPosteriorDensity_overSubLoci方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。