Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/R
- #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
- read.table("dat",sep="/")->X
- probb=function(x,p) {dbinom(x=x[[1]],size=x[[2]],prob=p)}
- MLE=function(p) prod(apply(X,1,function(x) probb(x,p)))
- q=(1:300)/100000
- plot(q,sapply(q,MLE))
- print(1/q[which.max(sapply(q,MLE))])
- #result: 1000
- 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])
- #result: 3000
- 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])
- #result: 4600
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement