## R: Dueling normals

More playing around with R. To create the graph above, I sampled 100 times from two different normal distributions, then plotted the ratio of times that the first distribution beat the second one on the y-axis. The second distribution always had a mean of 0, the mean of first distribution went from 0 to 4, this is plotted on the x-axis.

Here is my code:

1
2
3
4
5
6
7
8
9
10
11
| AbeatsB <- function(a,b) {
sum(a>b)/length(a)
}
x = seq(0,4,.001)
y = c()
for (i in x) {
y = c(y,AbeatsB(rnorm(100,i),rnorm(100,0)))
}
plot(x,y,pch=".",cex=2,col="blue") |

Tags: gaussian, normal, r

This entry was posted on Tuesday, May 18th, 2010 at 7:31 pm and is filed under feature, r, stats.
You can follow any comments to this entry through the RSS 2.0 feed.
You can leave a comment, or trackback from your own site.