5.1. kwant.digest – Random-access random numbers

Random-access random numbers

This module provides routines that given some input compute a “random” output that depends on the input in a (cryptographically) intractable way.

This turns out to be very useful when one needs to map some irregular objects to random numbers in a deterministic and reproducible way.

Internally, the md5 hash algorithm is used. The randomness thus generated is good enough to pass the “dieharder” battery of tests: see the function test of this module.

kwant.digest.uniform(input, salt='')

md5-hash input and salt and map the result to the [0,1) interval.

input must be some object that supports the buffer protocol (i.e. a string or a numpy/tinyarray array). salt must be a string or a bytes object.

kwant.digest.gauss(input, salt='')

md5-hash input and salt and return the result as a standard normal distributed variable.

input must be some object that supports the buffer protocol (i.e. a string or a numpy/tinyarray array). salt must be a string or a bytes object.

kwant.digest.test(n=20000)

Test the generator with the dieharder suite generating n**2 samples.

Executing this function may take a very long time.

Previous topic

4.3. kwant.linalg – Linear algebra routines

Next topic

5.2. kwant.rmt – Random matrix theory Hamiltonians

This Page