- Code: Select all
void AntiThetic::Skip(unsigned long numberOfPaths)
{
if (numberOfPaths ==0)
return;
if (OddEven)
{
OddEven = false;
numberOfPaths--;
}
InnerGenerator->Skip(numberOfPaths / 2);
if (numberOfPaths % 2)
{
MJArray tmp(GetDimensionality());
GetUniforms(tmp);
}
}
First, I am assuming that when skipping numberOfPaths paths, this means we skip numberOfPaths/2 (+1 if numberOfPaths odd) new variates from the inner generator, and numberOfPaths/2 antithetic samples.
Now consider a sample case:
OddEven = true - next sample should be a new variate from InnerGenerator, and
numberOfPaths = 4
The Skip function will:
1. Set OddEven = false
2. Set numberOfPaths = 3
3. Skip 1 variate in the InnerGenerator
4. Call GetUniforms(tmp), essentially just setting OddEven = true
5. return
On the next call we get a new variate, which is fine. Except that the InnerGenerator has only skipped 1 path, instead of the needed 2.
I have similar troubles using different combinations of OddEven and numberOfPaths.
There's also a possible bug?
Suppose the user decides to skip an odd number of paths immediately after creating an AntiThetic object. In this case the Skip function will:
1. Set OddEven = false
2. Make numberOfPaths even
3. Skip numberOfPaths/2 paths in the InnerGenerator
4. return
So OddEven is left false, but NextVariates has not been set to anything. The next call to GetUniforms will return rubbish.
Thanks for your help.
