蒙特卡罗方法中的重要性抽样(以C为单位)

发布于 2024-09-24 23:32:27 字数 129 浏览 1 评论 0原文

你好,我编写了一个代码,它使用“原始”蒙特卡罗采样技术成功地近似了一维、二维和三维积分。 我现在想通过使用“重要性采样”来改进这一点,因为显然这可以减少方差。我读过一些关于此的网页,但似乎没有一个特别清楚。我将如何实现这样的事情?非常感谢。杰克

Hiya, Ive written a code which successfully approximation one, two and three dimensional integrals using a 'crude' Monte-Carlo sampling technique.
I would now like to improve this by using 'importance sampling', as apparently this can reduce variance. I have read a few web pages about this but none seem particularly clear. How would I implement something like this? Many Thanks. Jack

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

和我恋爱吧 2024-10-01 23:32:27

没错,我发现了我的错误。我没有使用 PDF 的反积分来计算每个点的“权重”。对于任何感兴趣的人,我的条件循环如下所示:

for (i = 0; i <= N; i++) {
    X = (double) rand() / (double) RAND_MAX;
   integrand = function(inverse(X)) / PDF(inverse(X));
   sum = sum + integrand;
   sum2 = sum2 + (integrand * integrand);
}
average = sum / N;
average2 = sum2 / N;

其中 PDF 是我的概率密度函数,inverse 是 PDF 的逆积分。和average和average2分别代表和。

Right, I found my mistake. I wasn't using the inverse integral of the PDF to calculate the 'weight' of each point. For anyone whos's interested my conditional loop read like:

for (i = 0; i <= N; i++) {
    X = (double) rand() / (double) RAND_MAX;
   integrand = function(inverse(X)) / PDF(inverse(X));
   sum = sum + integrand;
   sum2 = sum2 + (integrand * integrand);
}
average = sum / N;
average2 = sum2 / N;

Where PDF is my probability density function, inverse is the inverse integral of the PDF. and average and average2 represent and respectively.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文