Skip to content

Cranley Patterson [CP76]

Descrition

Apply small modular shift vector to all points. It perfors : y_i = (x_i + v) \text{mod} 1.0, for some unfiorm random vector v

  • Shifts vector are uniformly selected in [-1, 1]. Hence, shift vector coordinates are uniform, but the direction vector are not uniform in the sphere.
  • The methods only operates on points in [0, 1].

Files

src/scramblers/CranleyPatterson.cpp  
include/utk/scrambling/ScramblingCranleyPatterson.hpp

Usage


CranleyPatterson scrambler
Usage: ./CranleyPatterson [OPTIONS]

Options:
  -h,--help                   Print this help message and exit
  -i,--input TEXT:FILE ... REQUIRED
                              Input file(s)
  -o,--out TEXT [out.dat]     Output file (format). {i} splits outputs in multiple files and token is replaced by index.
  -s,--seed UINT              Seed (unspecified means 'random')
  --silent                    Silence UTK logs
#include <utk/utils/PointsetIO.hpp>
#include <utk/utils/Pointset.hpp>
#include <utk/samplers/SamplerSobol.hpp>
#include <utk/scrambling/ScramblingCranleyPatterson.hpp>

int main()
{
    utk::Pointset<double> pts;

    utk::SamplerSobol sobol(2 /* dimension */);
    sobol.setRandomSeed(/* empty means random, can also pass a number */);

    // Check for no errors
    if (sobol.generateSamples(pts, 1024 /* Number of points */))
    {
        utk::ScramblingCranleyPatterson sc;
        sc.setRandomSeed();

        // In place:
        sc.Scramble(pts);
        // Results in another pointset
        utk::Pointset<double> pts2;
        sc.Scramble(pts, pts2);        
    }
}
import pyutk
samples = pyutk.Sobol(d=2, depth=0).isample(1024) # isample returns integers
sc = pyutk.CranleyPatterson()
).scramble(samples)               # returns a double array