0

When I add Gaussian noise to an array shouldnt the histogram be Gaussian? Although the noise is random, the distribution should be gaussian right? That is not what I get.

A=zeros(10);
A=imnoise(A,'gaussian');
imhist(A)
Amro
  • 123,847
  • 25
  • 243
  • 454
dither
  • 1
  • 1
  • 1
  • 1

4 Answers4

1

Two things could be going on:

  1. You don't have enough of a sample size, or

  2. The default mean of imnoise with gaussian distribution is 0, meaning you're only seeing the right half of the bell curve.

Try

imhist(imnoise(zeros(1000), 'gaussian', 0.5));
SCFrench
  • 8,244
  • 2
  • 31
  • 61
1

This is what your code is doing:

A = zeros(10);

mu = 0; sd = 0.1;                 %# mean, std dev
B = A + randn(size(A))*sd + mu;   %# add gaussian noise

B = max(0,min(B,1));              %# make sure that 0 <= B <= 1

imhist(B)                         %# intensities histogram

can you see where the problem is? (Hint: RANDN returns number ~N(0,1), thus the resulting added noise is ~N(mu,sd))


Perhaps what you are trying to do is:

hist( randn(1000,1) )

histogram

Amro
  • 123,847
  • 25
  • 243
  • 454
0

imnoise() is a function that can be applied to images, not plain arrays.
Maybe you can look into the randn() function, instead.

mjv
  • 73,152
  • 14
  • 113
  • 156
0

You might not see a bell-curve with a sampling frame of only 10.

See the central limit theorem.

http://en.wikipedia.org/wiki/Central_limit_theorem

I would try increasing the sampling frame to something much larger.


Reference:

Law of Large Numbers

http://en.wikipedia.org/wiki/Law_of_large_numbers

Gilead
  • 1,263
  • 10
  • 21