organofcorti

Navigator2.0

Oct 8th, 2011
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 1.70 KB | None | 0 0
  1. #navigator 2.0 by organofcorti is licensed under a Creative Commons Attribution 3.0 Unported License.
  2. #written in R (www.r-project.org)
  3. #finds the c
  4. #very simple, reliable, but slow
  5.  
  6. #estimated c value here:
  7. ctest<-300
  8.  
  9. #how far above and below ctest to test:
  10. test<-5
  11.  
  12. #can increase accuracy1&2 if you decrease test
  13. #or decrease accuracy1&2 if you increase test
  14. accuracy1<-0.01
  15. accuracy2<-0.1
  16.  
  17. #most recent webpage updates here
  18. #can edit code to scrape
  19. #make sure round is early enough that
  20. #no renormalising has occurred
  21. #data here from 2011-10-08 10:36:16 UTC
  22. shares<-176520
  23. currentScore<-543196.9628
  24. currentSecs<-9*60+43
  25. sharesPerSec<-shares/currentSecs
  26.  
  27. #calculates score for each c under investigation
  28. summary<-matrix(0,(2*test+1),3)
  29. i<-0
  30. for(c in (ctest-test):(ctest+test)){
  31.     i<-i+1 
  32.     score<-exp((1/sharesPerSec)/c)
  33.     k<-1;while(k<=shares) {k<-k+1;score<-score+exp((k/sharesPerSec)/c)}
  34.     summary[i,1]<-c
  35.     summary[i,2]<-score
  36.     summary[i,3]<-abs(log(summary[i,2]/currentScore))
  37.         if(summary[i,3]>accuracy){print(noquote(paste("Testing c=",c,", testing score is",trunc(score),", log ratio is",round(summary[i,3],digits=3))))}
  38.         else{print(noquote(paste("Testing c=",c,", testing score is",trunc(score),", log ratio is",round(summary[i,3],digits=3),"GOOD ESTIMATE")))}
  39. }
  40.  
  41. #the cell in col 3 closest to 0 corresponds
  42. #with the c value closest to the actual c
  43. if(min(summary[,3])<=accuracy2){print(noquote(paste("Best estimate, c=",summary[order(summary[,3]),1][1])))} else {
  44.     if(summary[order(summary[,3]),1][1]<(c-test)){print(noquote("c is less than your minimum test range"))} else {
  45.         if(summary[order(summary[,3]),1][1]>(c-test)){print(noquote("c is more than your maximum test range"))}
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment