English 中文(简体)
产生Parfor Loops的Qusi-Monte Carlo号码的问题
原标题:Problems Generating Scrambled Quasi-Monte Carlo Numbers in Parfor Loops

我正在提出一个问题,在街区形成半蒙特卡路。

问题是,当我在一个堂厅内产生多套此类数字时,每组人数最终都是相同的。 我举了一个非常简单的例子。

D = 3;
M = 1000;
numbers = cell(1,4);

mystream = qrandstream(scramble(sobolset(D), MatousekAffineOwen ));
myfun = @(x) qrand(mystream,x);

parfor i = 1:4
    numbers{i} = myfun(M);
end

为了证明这一问题,在采用该守则后,编号为{1}、编号为{2}、编号为{3}和编号为{4}的号码与以下数字相同:

>>numbers{1}(1:3,:)
ans =
          0.76          0.05          0.77
          0.33          0.96          0.23
          0.60          0.72          0.52

>> numbers{2}(1:3,:)
ans =
          0.76          0.05          0.77
          0.33          0.96          0.23
          0.60          0.72          0.52

我不禁要问,谁会想解决这一问题。 我的印象是,我必须做些什么,因为当我使用正常的随机数字流时,问题不会发生。

我应该指出,我不可能利用Qusi-Random 溪流的Syp或Leap特性等东西。 原因是,我在我平行运行的大型中型中型中型中型散射器方案中使用上述代码。

最佳回答

你们需要单独呼吁,向每位平行工人施压。 可以通过将有关古兰经的言论移至 par堂内,如:

D = 3;
M = 1000;
numbers = cell(1,4);

parfor i = 1:4
    mystream = qrandstream(scramble(sobolset(D), MatousekAffineOwen ));
    myfun = @(x) qrand(mystream,x);

    numbers{i} = myfun(M);
end

Why: Although MatousekAffineOwen does have a random scrambling order, MATLAB treats quasi-random sequences as a giant pre-defined array and sample data is computed on the fly each time a new sample is needed. Scrambling changes this order but the qrandstream object behaves as if it happened once, as soon as scramble is called. After that, the qrandstream is a deterministic stream of numbers. In non-parallel code (or if you use parfor without first enabling a matlabpool) this set up works fine with a single qrandstream b/c MATLAB keeps working through the (virtual) list with each call to qrand.

但按规定,每名工人都收到所有所需变数、功能等的副本。 因此,每名工人都得到半占多数的重复、预先确定的流体,结果每名工人的样本数量相同。 顺便说一句,这并不意味着所有数字都具有相同的价值。 就班轮而言,其范围大于平行工人(机械核心)的数量,同一工人将出现多处循环,因此与原产地相同。 在我的两台核心机器上,你的4个代号代码显示这种行为,编号为,编号为{1}=序号为<4}和<编码>编号为编号为{2}=编号为。

问题回答

暂无回答




相关问题
Weighted random numbers

I m trying to implement a weighted random numbers. I m currently just banging my head against the wall and cannot figure this out. In my project (Hold em hand-ranges, subjective all-in equity ...

Comprehensive information about hash salts

There are a lot of questions about salts and best practices, however most of them simply answer very specific questions about them. I have several questions which feed into one another. Assuming a ...

Generate unique names?

I am working on a php site in which we have to upload images from users.i have to rename that file for preventing conflicts in the name of the image. uniqid(rand(), true); and adding a large random ...

How to get two random records with Django

How do I get two distinct random records using Django? I ve seen questions about how to get one but I need to get two random records and they must differ.

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

热门标签