2011-06-01 62 views
2

我正在寻找帮助,从R和1的序列生成此图。我将它用作一系列测试中的一个来调查序列是否是随机的(通过查找模式在噪音中)。 注意:这不是功课!绘图随机性

例如,

> y <- rnorm(3000, 1, 2) 
> plot(y) 
>plot(y~y) 

我的数据是这样的形式:

>str(hv10k) 
num [1:100000] 0 1 1 1 0 0 1 0 0 0 ... 

rand1

更新:

继@RomanLuštrik的建议,这是我所到目前为止:

700约掷硬币:

​​

100000掷硬币:

100,000 coin toss

+0

好......什么是你的问题,你尝试过这么远吗? – Bobby 2011-06-01 08:15:58

+0

并且不要在标题中添加标签。 – Bobby 2011-06-01 08:16:32

+1

@RSouls:这就是标签的用途。 – Bobby 2011-06-01 08:25:28

回答

3

一种方法是

side <- 100 
my.zero <- matrix(sample(c(0,1), side^2, replace = TRUE), side) 
image(my.zero) 

编辑

你可以玩sample中的prob参数。

side <- 100 
my.zero <- matrix(sample(c(0,1), side^2, replace = TRUE, prob = c(0.8, 2)), side) 
image(my.zero) 

EDIT 2

y <- rnorm(10000, 1, 2) 
y <- matrix(ifelse(y > 0, 1, 0), ncol = 100) 
image(y, col = c("white", "black")) 

enter image description here

+0

@RomanLuštrik非常有趣,其中一些对我来说是新的。我必须问,如果你看到我的编辑,我的数据不是在矩阵和'(image(as.matrix(mydata))'不起作用 – 2011-06-01 08:38:15

+1

你必须把你的数据放入一个* m(或n * n)矩阵,尝试'矩阵(my.data,ncol = 1000)'。 – 2011-06-01 08:45:39

+0

我已经添加了另一个更接近于您可能要查找的内容的编辑 – 2011-06-01 11:02:20