[R] noisy quantisation

William Simpson william.a.simpson at gmail.com
Tue May 5 11:23:10 CEST 2009


The following creates a point process version of a sinewave (maybe
there's a better way):

p<-amp*cos(2*pi*freq*(1:n)/n ) + 0.5
as.numeric(runif(1:n)<p)

I get something like this:

1        o    oo oo    o  o    ooooo     o


0   ooo o      o     o o o              ooo ooo

In case it's not obvious, this is a noisy version of
1              ooooooo            ooooooo


0  ooooooo            ooooooo


I was wondering if anyone can suggest a way to create a version where
I get 0s, 1s, and 2s something like a noisy version of this:

2                 oooooooo                         oooooo


1            ooooo          ooooo         ooooo


0  ooooooo                        oooooooo

I am looking for a version of the top graph except with 3 levels instead of 2.

Thanks very much for any help

Bill




More information about the R-help mailing list