Learn R Programming

RMThreshold (version 1.1)

add.Gaussian.noise: 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.

Value

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$.

References

https://en.wikipedia.org/wiki/Gaussian_noise

See Also

Random generation for the normal distribution: rnorm

Examples

Run this code

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

Run the code above in your browser using DataLab