# [Bf-cycles] Random values in SVM nodes

storm kartochka22 at yandex.ru
Fri Mar 21 23:41:20 CET 2014

```Hi.

I have done experiments with rng generators, changing hashes, dimension
number reorder, hybrid stratified+QMC tricks (few lower bits using one
strategy, rest other), all that things.

I think for current trunk scheme (ordered for pixel integrt x,y, Sobol
QMC for rest dimensions) you need to allocate one or more extra
dimensions. There is no corellation problem except that Brecht use
Cranley-Patterson rotation only for 2 dimensions, and repeated for all
other. It make terrible aliasing for bidir case, as it allocate much
more dimension number. You just need to make better, wider hash, ideally
pixel (x,y) map to array with max dimension. I use not very scientific
proved but working good enough idea, to scramble seed using extra LCG.

Here is part of my patch, kernel_random.h, path_rng() function
Obviously, that is very ineffective as loop all dimensions from 0, so i
just wrap up them by 128. Also, I changed Cranley-Patterson by b-ary
shift, it is unrelated to corellation problem, but work good enough and
in theory do not ruine Sobol A property as Cranley-Patterson (not sure
it really make things better, need good blind tests to be sure)

uint d = (dimension & 127); // wrapup after 5 bounces in bidir!
uint r_r = *rng;
int i;
for ( i = 0; i < d; i++)
r_r = (1103515245*(r_r) + 12345); // glibc generator

result = result ^ r_r; // digital b-ary shift, same as
Cranley-Patterson but for every bit, and sum+mod degrade to xor for
binary
return (float)result * (1.0f/(float)0xFFFFFFFF);

```