add.Gaussian.noise {RMThreshold} | R Documentation |
Add Gaussian noise to a matrix
Description
The function adds Gaussian (i.e. normally distributed) noise to a matrix.
Usage
add.Gaussian.noise(mat, mean = 0, stddev = 1, symm = TRUE)
Arguments
mat |
Input matrix. |
mean |
Mean of the Gaussian noise to be added. |
stddev |
Standard deviation of the Gaussian noise to be added. |
symm |
A logical variable that determines if the matrix is to be symmetrized after adding the noise. |
Details
The function uses the rnorm
function to create the normally distributed noise and adds it to the input matrix. Optionally, the matrix is symmetrized by adding it's transpose and dividing by \sqrt 2
.
Value
The input matrix with noise added, optionally symmetrized.
Note
The matrix can not be symmetrized if it is not quadratic.
Author(s)
Uwe Menzel <uwemenzel@gmail.com>
References
https://en.wikipedia.org/wiki/Gaussian_noise
See Also
Random generation for the normal distribution: rnorm
Examples
## Not run:
N = 500
some.mat = matrix(rep(1, N*N), nrow = N)
some.mat[1:3, 1:10]
res <- rm.matrix.validation(some.mat) # not really a proper matrix for this approach.
## End(Not run)
## It can help to add Gaussian noise to an improper matrix
## Not run:
noisy.matrix <- add.Gaussian.noise(some.mat, mean = 0, stddev = 1, symm = TRUE)
noisy.matrix[1:3, 1:10]
res <- rm.matrix.validation(noisy.matrix) # better!
res <- rm.get.threshold(noisy.matrix) # about 4.3
## End(Not run)
[Package RMThreshold version 1.1 Index]