Search code examples
pythonrandomnumpynoise

What kind of noise is this?


What kind of noise does numpy.random.random((NX,NY)) create? White noise? If it makes a difference, I sometimes instead make 3D or 1D noise (argument is (NX,NY,NZ) or (N,)).


Solution

  • >>> help(numpy.random.random)
    Help on built-in function random_sample:
    
    random_sample(...)
        random_sample(size=None)
    
        Return random floats in the half-open interval [0.0, 1.0).
    
        Results are from the "continuous uniform" distribution over the
        stated interval.  To sample :math:`Unif[a, b), b > a` multiply
        the output of `random_sample` by `(b-a)` and add `a`::
    
          (b - a) * random_sample() + a
        ...
    

    As the help says, numpy.random.random() supplies a "continuous uniform" distribution.

    For a "Gaussian/white noise" distribution use numpy.random.normal().