- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用以下代码从逆 Gamma 分布中采样,修改我在网上找到的一些代码。我不是 C++ 编码方面的专家,所以我需要您的一些解释和帮助。
#include <iostream>
#include <fstream>
#include <random>
#include "boost/random.hpp"
#include "boost/generator_iterator.hpp"
#include <boost/math/distributions.hpp>
using namespace std;
int main(){
boost::mt19937 rng;
boost::math::inverse_gamma_distribution<>invg(2.0, 3.0);
cout << " probability variance > 50: " << boost::math::cdf(boost::math::complement(invg, 50.0));
boost::variate_generator<boost::mt19937& , boost::math::inverse_gamma_distribution<> > sampleIG(rng, invg);
for (int i = 0; i < 10; ++i)
{
double d = sampleIG();
std::cout << d << std::endl;
}
}
我得到的错误是:
In file included from /usr/include/boost/random.hpp:55:0,
from vesSimQ.cpp:5:
/usr/include/boost/random/variate_generator.hpp: In instantiation of ‘class boost::random::variate_generator<boost::random::mersenne_twister_engine<unsigned int, 32ul, 624ul, 397ul, 31ul, 2567483615u, 11ul, 4294967295u, 7ul, 2636928640u, 15ul, 4022730752u, 18ul, 1812433253u>&, boost::math::inverse_gamma_distribution<double> >’:
vesSimQ.cpp:20:98: required from here
/usr/include/boost/random/variate_generator.hpp:59:48: error: no type named ‘result_type’ in ‘class boost::math::inverse_gamma_distribution<double>’
typedef typename Distribution::result_type result_type;
^
vesSimQ.cpp: In function ‘int main()’:
vesSimQ.cpp:25:26: error: no match for call to ‘(boost::random::variate_generator<boost::random::mersenne_twister_engine<unsigned int, 32ul, 624ul, 397ul, 31ul, 2567483615u, 11ul, 4294967295u, 7ul, 2636928640u, 15ul, 4022730752u, 18ul, 1812433253u>&, boost::math::inverse_gamma_distribution<double> >) ()’
double d = sampleIG();
最佳答案
对于其他发行版,此错误是由于在 variate_generator 的实例化中使用 boost::math 而不是 boost::random 引起的。以下是有关如何创建 Weibull 随机数生成器的示例:
#include <boost/random/mersenne_twister.hpp> // For boost::mt19937
#include <boost/random/variate_generator.hpp>
#include <boost/random/weibull_distribution.hpp>
int main(){
double shape = 3.0;
double scale = 0.5;
boost::mt19937 rng(12);
boost::random::weibull_distribution<> myWeibull(shape, scale);
boost::random::variate_generator<boost::mt19937&, boost::random::weibull_distribution<> > rand_Weibull(rng, myWeibull);
double rn;
for (int i=0; i < 10; ++i)
{
rn = rand_Weibull();
cout << rn << endl;
}
}
我看到虽然在 boost::random 范围内有 Gamma 分布,但没有逆 Gamma 分布。
我安装了 Boost 1.60.0,它有一个名为\boost_1_60_0\libs\math\test\的文件夹,其中包含一些可能对您有帮助的代码。
关于c++ - 使用 boost C++ 从逆 Gamma 分布生成随机样本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34240443/
我正在寻找一个简单的 Gamma 校正公式,适用于值在 0 到 255 之间的灰度图像。 假设我的屏幕的 Gamma 值为 2.2(它是 LCD 屏幕,因此我可能需要使用更复杂的过程来估计它,但我们假
是否可以通过使用某些图像统计信息的算法来估算gamma correction的最佳 Gamma 参数?所谓“最佳”,是指校正后的图像平均应该对人类“看起来不错”。 最佳答案 如果图像像素的缩放比例在0
我有我正在尝试建模的半连续数据(许多精确的零和连续的正结果)。我从 Zuur 和 Ieno 的 R 中零膨胀模型初学者指南中学到了大量关于零质量的建模数据,它区分了零膨胀 Gamma 模型和他们所描述
我需要为相当大的 x 计算 Gamma(x+1/2)/Gamma(x)。如果我只使用 http://docs.scipy.org/doc/scipy/reference/generated/scipy
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 要求我们推荐或查找工具、库或最喜欢的场外资源的问题对于 Stack Overflow 来说是偏离主题的,
嗨,我是 tensorflow 的新手,我正在尝试在 tensorflow 中生成随机 Gamma 分布,就像 numpy.random.gamma 我的 numpy 代码是:- self._lamb
我正在研究 a package ,它使用来自 RcppArmadillo 的随机数。该软件包运行 MCMC 算法,为了获得精确的再现性,用户应该能够设置随机数种子。执行此操作时,似乎用于从 Gamma
我想计算我拥有的一组数据的 Gamma CDF。我已经计算了 alpha 和 beta 参数,但是我不确定如何在 R 中计算 CDF(是否有类似 Matlab 的 gamcdf 的东西?)。 我看到有
我想使用以下程序计算 gamma(-170.1): program arithmetic ! program to do a calculation real(8) :: x x = GAMMA
我想计算我拥有的一组数据的 Gamma CDF。我已经计算了 alpha 和 beta 参数,但是我不确定如何在 R 中计算 CDF(是否有类似 Matlab 的 gamcdf 的东西?)。 我看到有
我有一个形状和尺度参数为 2.126、0.370 的 Gamma 分布。 您可以使用以下代码绘制它: shape, scale = 2.126, 0.370 # mean=4, std=2*sqrt
我是 python 的新手,我正在尝试进行 Gamma 回归,我希望获得与 R 类似的估计,但我无法理解 python 的语法并且它会产生错误,关于如何解决它的一些想法。 我的 R 代码: set.s
有很多扫描仪允许在它们的设置中设置图像 Gamma ,但不幸的是,这个 Gamma 是在扫描仪软件中调整的,而不是在扫描仪端(通过模拟方式或至少使用分辨率高于 8 位的 ADC) .比如说,我们最初从
关闭。这个问题需要debugging details .它目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and th
在 .NET 中调整图像的亮度对比度和 Gamma 值的简单方法是什么 我会自己发布答案以供稍后查找。 最佳答案 c# and gdi+ have a simple way to control th
我有一个方法可以返回输入的阶乘。它非常适用于整数,但我不知道如何让它适用于小数。 目前我的方法是这样的: public static double factorial(double d) {
我有一些对比度非常微弱且有相当多噪点的成像数据,当我使用线性色标显示时,显示效果不佳。在 imageJ 或 photoshop 等成像软件中,有一条色调曲线,可以对其进行调整以非线性方式增强对比度,并
我正在玩 xgboost,有一些财务数据,想尝试 Gamma 回归作为目标。 cvs 根据 xgboost 文档,stratified 是一个 bool 值,指示是否应根据结果标签的值对折叠采样进行
目前,我使用以下公式在光照通过后对颜色进行 Gamma 校正(将它们从 RGB 颜色空间转换为 sRGB 颜色空间): output = pow(color, vec3(1.0/2.2)); 这个公式
我们有qgamma在 R 和 gamm.inv在 excel 中,我无法使用 invgamma 获得相同的结果python中的函数。例如在excel中GAMMA.INV(0.99,35,0.08)=4
我是一名优秀的程序员,十分优秀!