[R] White Noise

(Ted Harding) Ted.Harding at nessie.mcc.ac.uk
Sun Jan 22 17:54:18 CET 2006


On 22-Jan-06 Laura Quinn wrote:
> I'm wanting to create a series of near-identical matrices
> via the addition of "white noise" to my starting matrix.
> Is there a function within R which will allow me to do this?
> 
> Thank you
> 
> Laura Quinn

The short ansdwer is: Yes, just do it as you descibe!

For example:

  M<-matrix(c(2,4,6,1,3,5),nr=2)
  M
  #      [,1] [,2] [,3]
  # [1,]    2    6    3
  # [2,]    4    1    5

  M + 0.01*runif(6)
  #          [,1]     [,2]     [,3]
  # [1,] 2.009196 6.000863 3.009307
  # [2,] 4.000973 1.008916 5.006934

You have certainly added "white noise" since, considered
as a sequence, the elements of runif(6) are independent.

It gets more interesting, however, if you want the result
to be more constrained then you have stated in your query.

Ensuring that the expected result is equal to the starting
matrix, or that the added noise has a specified distribution
(e.g. gaussian) is easy: just change the "0.01*runif()".

But if you want to ensure that (e.g.) the elements of the
result are positive, or that the result (if square) is
positive definite, or is symmetric, or is a correlation
matrix, then some further thought would have to be given
to just how best to proceed. The resulting "tuned" procedure
would then be better wrapped in a function.

If you would, perhaps, state more fully what you want to
achieve it may be possible to suggest something.

I'm not, myself, aware of a function in R which is designed
to do this job under the sort of constraints above, or
others (and, if unconstrained, you hardly need a special
function for it).

Hoping this helps,
Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 22-Jan-06                                       Time: 16:54:15
------------------------------ XFMail ------------------------------




More information about the R-help mailing list