Esempio n. 1
0
def gsl_uniform_sequence(n, seed=None):
    """
    Return sample sequence of length n from a uniform distribution.

    """
    try:
        import pygsl.rng
    except ImportError:
        print "Import error: not able to import pygsl"
        return
    rng = pygsl.rng.rng()
    random._inst = random.Random()
    if seed is None:
        seed = random.randint(1, 2**32 - 1)
    rng.set(seed)

    return rng.uniform(n)
Esempio n. 2
0
def gsl_uniform_sequence(n,seed=None):
    """
    Return sample sequence of length n from a uniform distribution.

    """
    try:
        import pygsl.rng
    except ImportError:
        print "Import error: not able to import pygsl"
        return
    rng=pygsl.rng.rng()
    random._inst = random.Random()
    if seed is None:
        seed=random.randint(1,2**32-1)
    rng.set(seed)

    return rng.uniform(n)
Esempio n. 3
0
 def Step(self, rng, step_size):
     old_x = self._data
     
     u = rng.uniform();
     new_x = u * 2 * step_size - step_size + old_x;
     self._data = new_x