Is it possible to set the seed for the monte carlo simulation

Hi all

I am using rfluxmtx and rcontrib to perform computation on the daylight coefficients. As far as I understand it, Radiance uses monte Carlo approach to solve for the daylight coefficients such as each time I run the simulation, I will get different results.

I am wondering if it is possible to eliminate this? By perhaps setting a seed? Or by perhaps switch to a deterministic method, if available?

Thanks a lot.

You can use the -u0 setting in rcontrib to switch to a predetrmined low-discrepancy sequence rather than a random number generator. This doesn’t remove all randomness, however. There are places where frandom() is still called, but if you replace the #define in src/common/random.h for frandom() to “0.5” and recompile everything, you can turn this off completely.

-Greg

Ahh I see. Do I need to replace other #define? There are random(), srandom() and then the frandom()

Thanks in advance.

No, I don’t think so. Just

#define frandom() 0.5

Dear @Greg_Ward

So I just tried your approach by revising the definition of frandom(), but the behavior still remains. May I know what I am missing? I have recompiled two times and ensured that I used the newly complied binary to generate the results.

Thanks!

What random behavior are you seeing? Did you run with the “-u0” option? The rendering will still appear somewhat noisy, but you should get the same rendering if you run it twice with the same inputs. With different inputs, your results will be different unless you are using rpict and also set “-ps 1”.

If your inputs are different, you can try running with “-u1” with your compiled change, but the results will suffer from the lack of any sample distribution.

Ahh, I think I misunderstood.

I thought just by changing the definition of frandom would completely eliminate the issue. However, it seemed that I have to both set the -u0 AND change frandom to work. Is that correct?

Yes, and use “rpict -u0 -ps 1” if you want comparative results from different inputs.