Advertisement
organofcorti

How to hop 9 mining simulation example

Nov 19th, 2011
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 2.48 KB | None | 0 0
  1.  
  2. #mining sim for 'How to hop 9'
  3. D<-1200000;B<-50
  4. maxRounds<-100;hop1<-.25*D;hop2<-0.5*D;hop3<-D
  5. minerHashrate <-1; poolHashrate <-1000
  6. earnings<-matrix(0,maxRounds,8)
  7. totalRoundShares<-rgeom(maxRounds,1/D)+1
  8. for(i in 1:maxRounds){
  9.     earnings[i,1]<-i
  10.     earnings[i,2]<-totalRoundShares[i]
  11.     earnings[i,3]<-earnings[i,4]<-earnings[i,5]<-minerHashrate/poolHashrate*B
  12.     earnings[i,6]<-earnings[i,7]<-earnings[i,8]<-B/D*minerHashrate/poolHashrate*totalRoundShares[i]
  13.     if(totalRoundShares[i]>hop1){earnings[i,3]<-minerHashrate/poolHashrate*hop1/totalRoundShares[i]*B;earnings[i,6]<-B/D*hop1*minerHashrate/poolHashrate}
  14.     if(totalRoundShares[i]>hop2){earnings[i,4]<-minerHashrate/poolHashrate*hop2/totalRoundShares[i]*B;earnings[i,7]<-B/D*hop2*minerHashrate/poolHashrate}
  15.     if(totalRoundShares[i]>hop3){earnings[i,5]<-minerHashrate/poolHashrate*hop3/totalRoundShares[i]*B;earnings[i,8]<-B/D*hop3*minerHashrate/poolHashrate}
  16. }
  17. x<-cumsum(earnings[,2])
  18. prop1<-cumsum(earnings[,3]);pps1<-cumsum(earnings[,6])
  19. prop2<-cumsum(earnings[,4]);pps2<-cumsum(earnings[,7])
  20. prop3<-cumsum(earnings[,5]);pps3<-cumsum(earnings[,8])
  21. ylim1<-max(max(prop1),max(pps1));ylim2<-max(max(prop2),max(pps2));ylim3<-max(max(prop3),max(pps3))
  22.  
  23. png('miner-earning-2simulation%03d.png')
  24. plot(x,prop1,type='l',ylim=c(0,ylim1),col='red',lwd=2,axes=F,xlab='',ylab='')
  25. par(new=T)
  26. plot(x,pps1,type='l',ylim=c(0,ylim1),col='blue',lwd=2,axes=F,xlab='',ylab='')
  27. axis(1,at=x,labels=earnings[,1]);axis(2)
  28. title(xlab='Block number',ylab='Bitcoin earned',main=paste('Cumulative earned for',hop1/D,'*D shares\n D=1200000'))
  29. legend('topleft',c('Proportional miner','PPS miner'),col=c('red','blue'),lty=1,lwd=2,bty='n')
  30.  
  31. plot(x,prop2,type='l',ylim=c(0,ylim2),col='red',lwd=2,axes=F,xlab='',ylab='')
  32. par(new=T)
  33. plot(x,pps2,type='l',ylim=c(0,ylim2),col='blue',lwd=2,axes=F,xlab='',ylab='')
  34. axis(1,at=x,labels=earnings[,1]);axis(2)
  35. title(xlab='Block number',ylab='Bitcoin earned',main=paste('Cumulative earned for',hop2/D,'*D shares\n D=1200000'))
  36. legend('topleft',c('Proportional miner','PPS miner'),col=c('red','blue'),lty=1,lwd=2,bty='n')
  37.  
  38. plot(x,prop3,type='l',ylim=c(0,ylim3),col='red',lwd=2,axes=F,xlab='',ylab='')
  39. par(new=T)
  40. plot(x,pps3,type='l',ylim=c(0,ylim3),col='blue',lwd=2,axes=F,xlab='',ylab='')
  41. axis(1,at=x,labels=earnings[,1]);axis(2)
  42. title(xlab='Block number',ylab='Bitcoin earned',main=paste('Cumulative earned for D shares\n D=1200000'))
  43. legend('topleft',c('Proportional miner','PPS miner'),col=c('red','blue'),lty=1,lwd=2,bty='n')
  44. dev.off()
  45.  
  46.  
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement