Hey guys, how do I add Gaussian noise of zero mean, 20% variance to a matrix of samples in MATLAB? Thanks.
Name:
Anonymous2010-03-21 7:54
MATLAB
come back when you use a real man's CAS like Mathematica or Maxima
Name:
atarkri2010-03-22 22:13
A Gaussian of mean zero, variance .2:
f(x) = (.08*π)-1/2 e-(x2/.08)
In order to apply this to the cells in a matrix (i.e. discrete data) we must take a discretized sample of this distribution and convolute it with the data, g(x):
f \conv g = \integral_{-\infty}^{\infty} f(u)f(x-u) du
Or more simply, we must multiply the function f by g, slide f over, and multiply it again.
We take a discretized sample, say f(-.5), f(0), and f(.5):
.0876, 1.9947, .0876
i.e. multiply each data by the mask
[.0876][1.9947][.0876]
where the data to be modified is the center of the mask.
and (skipping g[0]) then take
g[1] = .0876*g[0] + 1.9947*g[1] + .0876*g[2]
continuing up until g[length-1] .
If instead we are talking about a two-dimensional matrice (i.e. an image) then we must convolve by the function f(x,y)
f(x,y) = (.08*π)-1/2 e-((x2 + y2)/.08)
or, we must multiply each data point by the mask:
[.0038][0.0876][.0038]
[.0876][1.9947][.0876]
[.0038][0.0876][.0038]
where the data we are modifying is in the center of the mask. (notice f(sqrt(2)/2) = .0038)