tsbertalan
tsbertalan

Reputation: 1550

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,)).

Upvotes: 2

Views: 2651

Answers (2)

monkut
monkut

Reputation: 43830

>>> 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().

Upvotes: 7

MaxPowers
MaxPowers

Reputation: 5486

White noise has a mean of 0 and standard deviation of 1. Since,

std(numpy.random.random(1000000)) ≈ 0.2889

and

mean(numpy.random.random(1000000)) ≈ 0.5

numpy.random.random() does not create white noise; per definition. But there is nothing that could create white noise, since it is a theoretical construct.

Upvotes: 1

Related Questions