[R] Generating correlated data from uniform distribution

Ken Knoblauch knoblauch at lyon.inserm.fr
Sat Jul 2 09:06:48 CEST 2005


While you are looking at weird distributions, here is one that 
 we have used in experiments on noise masking to explore the 
 bandwidth of visual mechanisms 

D'Zmura, M., & Knoblauch, K. (1998). Spectral bandwidths for the detection of 
color. 
Vision Research, 20, 3117-28 and
G. Monaci, G. Menegaz, S. Susstrunk and K. Knoblauch Chromatic Contrast 
Detection in Spatial 
Chromatic Noise Visual Neuroscience, Vol. 21, No 3, pp. 291-294, 2004

N <- 10000
x <- runif(N, -.5,.5)
y <- runif(N, -abs(x), abs(x))
plot(x,y)

y is not uniform but it is conditional on x.  The plot reveals
why we called this "sectored noise".

HTH

ken

--------------------------------------------------------
"Jim Brennan" <jfbrennan at rogers.com> writes:

> Yes you are right I guess this works only for normal data. Free advice
> sometimes comes with too little consideration :-)

Worth every cent...

> Sorry about that and thanks to Spencer for the correct way.

Hmm, but is it? Or rather, what is the relation between the
correlation of the normals  and that of the transformed variables? 
Looks nontrivial to me.

Incidentally, here's a way that satisfies the criteria, but in a
rather weird way:

N <- 10000
rho <- .6
x <- runif(N, -.5,.5)
y <- x * sample(c(1,-1), N, replace=T, prob=c((1+rho)/2,(1-rho)/2))

-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: 
(+45) 35327907

____________________
Ken Knoblauch
Inserm U371, Cerveau et Vision
Department of Cognitive Neurosciences
18 avenue du Doyen Lepine
69500 Bron
France
tel: +33 (0)4 72 91 34 77
fax: +33 (0)4 72 91 34 61
portable: 06 84 10 64 10
http://www.lyon.inserm.fr/371/




More information about the R-help mailing list