开发者

Reproduce frequency matrix plot

I have a plot that I would like to recreate within R. Here is the plot:

Reproduce frequency matrix plot

From: Boring, E. G. (1941). Statistical frequencies as dynamic equilibria. Psychological Review, 48(4), 279.

This is a little above my paygrade (abilities) hence asking here. Boring states:

On the first oc开发者_C百科casion A can occur only 'never' (0) or 'always' (1). On the second occasion the frequencies are 0,1/2, or 1; on the third 0, 1/3, 2/3, or 1 etc, etc.

Obviously, you don't have to worry about labels etc. Just a hint to generate the data and how to plot would be great. ;) I have no clue how to even start...


here is an example:

library(plyr)
ps <- ldply(1:36, function(i)data.frame(s=0:i, n=i))
plot.new()
plot.window(c(1,36), c(0,1))
apply(ps, 1, function(x){
  s<-x[1]; n<-x[2];
  lines(c(n, n+1, n, n+1), c(s/n, s/(n+1), s/n, (s+1)/(n+1)), type="o")})
axis(1)
axis(2)

ps represents all points. Each point has two children. So draw lines from each point to the children.

Reproduce frequency matrix plot


A solution using base graphics:

x <- 1:36
boring <- function(x, n=1)n/(x+n-1)

plot(x, boring(x), type="l", usr=c(0, 36, 0, 1))
for(i in 1:36){
  lines(tail(x, 36-i+1), head(boring(x, i), 36-i+1), type="o", cex=0.5)
  lines(tail(x, 36-i+1), 1-head(boring(x, i), 36-i+1, type="o", cex=0.5))
}

Reproduce frequency matrix plot

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜