问题标签 [montecarlo]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
251 浏览

c++ - 统计分布类型的 C++ 模板用法

这是另一个问题的后续(https://stackoverflow.com/questions/10712659/c-class-design-for-monte-carlol-simulation

我计划使用模板实现一个统计分布类。我想让 Distribution 成为 Entity 类的属性。此 Distribution 类可以采用几种不同的形式 - TriangleDistribution、NormalDistribution 和 WeightedDistribution,但这些仅在运行时才知道。他们共享大多数方法,但每种类型也可能有一些自定义方法,例如。正常分布的 setMean,WeightedDistribution 的 setWeights。

据我了解,C++ 模板是指一种类型,然后用于确定要使用的实现。有人建议我使用模板实现不同的分发类型。

虽然我认为我了解 C++ 模板的概念,但我不确定如何实施它们来解决这个分布问题。我是否使用模板专业化创建类似以下内容?:

这将需要为每种分发类型创建多种类型。TIA 伙计们。皮特

0 投票
1 回答
686 浏览

machine-learning - Gibbs 采样代码

这里有没有人使用一些测试实现了吉布斯抽样。我必须实施 Gibbs 抽样,但我在将其确定为实施级别时遇到了问题。

----如何以及从哪里选择测试数据?
----如何根据该数据创建贝叶斯网络?(据我了解,您应该有一些贝叶斯网络可供采样。)

如果有人能在这方面指导我,那将是很大的帮助....

0 投票
1 回答
95 浏览

statistics - Given measurements from a event series as input, how do I generate an infinite input series with the same profile?

I'm currently working with a system that makes scheduling decisions based on a series of requests and the state of the system.

I would like to take the stream of real inputs, mock out some of the components, and run simulations against the rest. The idea is to use it for planning with respect to system capacity (i.e. when to scale certain components), tracking down certain failure modes, and analyzing the effects of changes to the codebase (i.e. simulations with version A compared to simulations with version B).

I can do everything related to this, except generate a suitable input stream. Replaying the exact input from production hasn't been very helpful because it's hard to get a long enough data stream to tease out some of the behavior that I'm trying to find. In other words, if production falls over at 300 days of input, I don't have enough data to find out until after it fell over. Repeating the same input set has been considered; but after a few initial tries, the developers all agree that the simulation seems to "need more random".

About this particular system:

  • The input is a series of irregularly spaced events (i.e. a stochastic process with discrete time and continuous state space).
  • Properties are not independent of each other.
  • Even the more independent of the properties are composites of other properties that will always be, by nature, invisible to me (leading to a multi-modal distribution).
  • Request interval is not independent of other properties (i.e. lots of requests for small amounts of resources come through in a batch, large requests don't).
  • There are feedback loops in it.
  • It's provably chaotic.

So:

Given a stream of input events with a certain distribution of various properties (including interval), how do I generate an infinite stream of events with the same distribution across a number of non-independent properties?

Having looked around, I think I need to do a Markov-Chain Monte-Carlo Simulation. My problem is figuring out how to build the Markov-Chain from the existing input data.

0 投票
1 回答
2760 浏览

performance - 分支分歧、CUDA 和动力学蒙特卡洛

所以,我有一个代码,它在格子上使用 Kinetic Monte Carlo 来模拟某些东西。我正在使用 CUDA 在我的 GPU 上运行此代码(尽管我相信同样的问题也适用于 OpenCl)。

这意味着我将我的格子分成小的子格子,每个线程都在其中一个上运行。由于我在做 KMC,每个线程都有这个代码:

A 对于不同的线程是不同的,u 也是不同的,100 只是一个随机数。在代码中,这可能是 1000 甚至 10000。

那么,当一个线程通过 if 的时候,我们不会有分支分歧吗?这会对性能造成多大的影响?我知道答案取决于 if 子句中的代码,但是随着我添加越来越多的线程,这将如何扩展?

任何关于我如何估计性能损失/收益的参考也将受到欢迎。

谢谢!

0 投票
1 回答
366 浏览

random - GSL 蒙特卡洛积分函数使用什么随机发生器?如何更换种子?

在此先感谢您的帮助。我在网站上找不到关于 GSL 蒙特卡罗集成函数使用什么随机数生成器的文档。我想知道的原因是我多次运行我的程序,期望得到不同的结果,但每次都得到完全相同的值。有没有一种简单的方法可以更改随机数生成器的种子?

弗雷德

0 投票
1 回答
1942 浏览

matlab - 如何使用 MATLAB 代码进行蒙特卡罗模拟?

我有三个参数,例如 X =( Min=5,Mode=7,Max=10); Y=(Min=3,Mode=5,Max=10); Z=(最小=5,模式=7,最大=12)。P = X Y Z;现在我如何编写一个 MATLAB 代码进行 10000 次迭代的蒙特卡罗模拟以获得 P 值?以及如何绘制输出 P 值的正态分布和累积分布?

0 投票
1 回答
645 浏览

matlab - MATLAB 中的蒙特卡罗

当我尝试运行这个程序时:

我收到此错误:

错误:应为“标识符”,找到“)”。

其中方差分别为0.020.005,均值分别为0.2420.536

0 投票
1 回答
534 浏览

r - R:运行标准差

我需要计算均值向量的“运行”标准差,就像样本量在增加一样计算它们。换句话说,我需要计算 mean_y[1]、mean_y[1] 和 mean_y[2]、mean_y[1]、mean_y[2]、mean_y[3] 等的 sd,

在哪里:

尝试应用相同的标准(因此,不明确使用循环),我为运行均值向量的标准差生成了以下代码:

这是因为 var(mean(x)) = 1/n*var(x)。对我来说,代码似乎没问题。但是,当我将运行均值及其置信区间与 i(增加的样本量)绘制成图时,95% 的波段与均值完全一致!

代码是:

基本原理是生成一个图表,显示随着样本量不断增加,估计量“mean_y”的收敛性。

谁能帮我?可能存在某种基本错误,无论是在se公式中还是在lowerand中upper。谢谢!!斯特凡诺

0 投票
2 回答
790 浏览

azure - 用于模拟的 Windows Azure

我们正在考虑使用 Windows Azure 进行模拟。大约 100 个 VM 节点,每个节点都在处理它的问题集并将结果报告给主节点。

我已经从 Web UI 创建了 VM 实例。为了使其工作,我们需要使用 Azure API 来启动服务器并在完成后关闭它们。

有没有人有这样的经验?我正在寻找建议,陷阱等。

谢谢。

0 投票
1 回答
1388 浏览

python - Python大迭代次数失败

我使用多处理模块在 Python 中编写了简单的蒙特卡罗 π 计算程序。它工作得很好,但是当我为每个工人通过 1E+10 次迭代时,出现了一些问题,结果是错误的。我不明白是什么问题,因为在 1E+9 次迭代中一切都很好!