tags:

views:

79

answers:

4

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)
A: 

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

mjv
A: 

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  A: 

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
A: 

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

alt text

Amro

related questions