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


C++ Gaussian::integrate方法代码示例

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


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

示例1: testDifferentialEntropy

void testDifferentialEntropy(){
  std::cout << "Testing Differential Entropy." << std::endl;
  
  fracfloat_t samples[DE_TEST_SIZE];
  
  std::default_random_engine generator;
  std::normal_distribution<fracfloat_t> distributions[DISTSIZE];
  
  distributions[0] = std::normal_distribution<fracfloat_t>(0.0,1.0);
  distributions[1] = std::normal_distribution<fracfloat_t>(0.1,4.0);
  distributions[2] = std::normal_distribution<fracfloat_t>(2.0,1.0);
  distributions[3] = std::normal_distribution<fracfloat_t>(5.0,8.0);
  
  
  for(unsigned i = 0; i < DE_TEST_SIZE; i++){
    samples[i] = distributions[i % DISTSIZE](generator);
  }
  
  Gaussian g = Gaussian(samples, DE_TEST_SIZE);
  MultiGaussian mg = MultiGaussian::fitGaussianKernel(samples, DE_TEST_SIZE, (unsigned)sqrt(DE_TEST_SIZE));
  
  fracfloat_t supportStart = min<fracfloat_t>(samples, DE_TEST_SIZE) * 2;
  fracfloat_t supportEnd = max<fracfloat_t>(samples, DE_TEST_SIZE) * 2;
  
  std::cout << "Gaussian: " << g << std::endl;
  std::cout << "Multi Gaussian: " << mg << std::endl;
  
  std::cout << "Integral gaussian approximation: " << g.integrate(supportStart, supportEnd, 1000) << std::endl;
  std::cout << "Integral multigaussian approximation: " << mg.integrate(supportStart, supportEnd, 1000) << std::endl;
  std::cout << "Integral 10: " << mg.approximateDifferentialEntropyFromIntegral(supportStart, supportEnd, 10) << std::endl;
  std::cout << "Integral 100: " << mg.approximateDifferentialEntropyFromIntegral(supportStart, supportEnd, 100) << std::endl;
  std::cout << "Integral 1000: " << mg.approximateDifferentialEntropyFromIntegral(supportStart, supportEnd, 1000) << std::endl;
  std::cout << "Distribution Trick:      " << mg.approximateDifferentialEntropyFromSamples(Array<fracfloat_t>(samples, DE_TEST_SIZE / 1)) << std::endl;
  std::cout << "Distribution Trick 1/2:  " << mg.approximateDifferentialEntropyFromSamples(Array<fracfloat_t>(samples, DE_TEST_SIZE / 2)) << std::endl;
  std::cout << "Distribution Trick 1/4:  " << mg.approximateDifferentialEntropyFromSamples(Array<fracfloat_t>(samples, DE_TEST_SIZE / 4)) << std::endl;
  std::cout << "Distribution Trick 1/8:  " << mg.approximateDifferentialEntropyFromSamples(Array<fracfloat_t>(samples, DE_TEST_SIZE / 8)) << std::endl;
  std::cout << "Distribution Trick 1/16: " << mg.approximateDifferentialEntropyFromSamples(Array<fracfloat_t>(samples, DE_TEST_SIZE / 16)) << std::endl;
  
}
开发者ID:bfisch02,项目名称:csax_cpp,代码行数:39,代码来源:unittest.cpp


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