Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n<-100;
- mtres<-rep(0,n)
- nsim<-10000
- for (t in 1:647) {
- tourres<-matrix(rep(0,n*n),nrow=n,ncol=n)
- for (k in 2:n) {
- for (l in 1:(k-1)) {
- tourres[k,l]<-sample(c(0,1),1)
- tourres[l,k]<-1-tourres[k,l]
- }
- }
- mtres<-mtres+sort(rowSums(tourres))
- }
- plot(mtres/nsim,type='l')
- me<-(n-1)/2
- se<-sqrt((n-1)/4)
- curve(qnorm(x/n,me,se),from=0,to=n,add=T,col='red')
- curve(qbinom((x-0.5)/n,n-1,1/2),from=0,to=n,add=T,col='blue')
- > mtres/nsim
- [1] 37.0529 38.8178 39.8103 40.5246 41.1004 41.5688 41.9787 42.3477 42.6726
- [10] 42.9847 43.2639 43.5249 43.7751 44.0082 44.2256 44.4402 44.6479 44.8379
- [19] 45.0221 45.2040 45.3828 45.5611 45.7286 45.8976 46.0504 46.2097 46.3602
- [28] 46.5153 46.6663 46.8137 46.9510 47.0826 47.2206 47.3658 47.5138 47.6548
- [37] 47.7893 47.9121 48.0304 48.1495 48.2822 48.4198 48.5623 48.6912 48.8136
- [46] 48.9286 49.0407 49.1549 49.2819 49.4216 49.5650 49.7027 49.8218 49.9305
- [55] 50.0414 50.1550 50.2857 50.4243 50.5592 50.7022 50.8349 50.9580 51.0779
- [64] 51.1992 51.3318 51.4758 51.6228 51.7688 51.9080 52.0362 52.1782 52.3212
- [73] 52.4726 52.6264 52.7842 52.9417 53.0956 53.2592 53.4346 53.6118 53.7920
- [82] 53.9683 54.1521 54.3493 54.5514 54.7600 54.9891 55.2233 55.4744 55.7365
- [91] 56.0231 56.3181 56.6480 57.0165 57.4239 57.9007 58.4657 59.1880 60.1857
- [100] 61.9515
- > qbinom(((1:n)-0.5)/n,n-1,1/2)
- [1] 37 39 40 41 41 42 42 42 43 43 43 44 44 44 44 44 45 45 45 45 45 46 46 46 46
- [26] 46 46 47 47 47 47 47 47 47 48 48 48 48 48 48 48 48 49 49 49 49 49 49 49 49
- [51] 50 50 50 50 50 50 50 50 51 51 51 51 51 51 51 51 52 52 52 52 52 52 52 53 53
- [76] 53 53 53 53 54 54 54 54 54 55 55 55 55 55 56 56 56 57 57 57 58 58 59 60 62
- >
Add Comment
Please, Sign In to add comment