SHOW:
|
|
- or go back to the newest paste.
1 | #!/usr/bin/R | |
2 | #first execute in shell: links2 -dump http://www.reddit.com/r/Ingress/comments/25um5v/lets_create_capsule_hacks_statistics/|grep '[0-9]/[0-9]'|sed -e 's/^[^0-9]*//' -e 's/ .*//' -e 's/\([0-9/]\+\).*/\1/'|grep '[0-9]/[0-9]' >dat | |
3 | read.table("dat",sep="/")->X | |
4 | probb=function(x,p) {dbinom(x=x[[1]],size=x[[2]],prob=p)} | |
5 | MLE=function(p) prod(apply(X,1,function(x) probb(x,p))) | |
6 | q=(1:300)/100000 | |
7 | plot(q,sapply(q,MLE)) | |
8 | - | print(q[which.max(sapply(q,MLE))]) |
8 | + | print(1/q[which.max(sapply(q,MLE))]) |
9 | #result: 1000 | |
10 | n=10*1:5000; i=1; while(qbinom(p=0.05,size=n[i],prob=1/1000)<1) {i<<-i+1};print(n[i-1]) | |
11 | #result: 3000 | |
12 | n=10*1:5000; i=1; while(qbinom(p=0.01,size=n[i],prob=1/1000)<1) {i<<-i+1};print(n[i-1]) | |
13 | #result: 4600 |