Bitcoin Forum
May 04, 2024, 09:05:48 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Tutorial: Using R to statistically test a die for bias  (Read 622 times)
pf (OP)
Full Member
***
Offline Offline

Activity: 176
Merit: 105


View Profile
August 19, 2015, 11:37:10 AM
Last edit: August 19, 2015, 11:57:05 AM by pf
 #1

In the following, we assume a 6-sided die. If you have another type of die, adjust accordingly.

Now, roll your die a hundred times and record the results on a piece of paper or an offline computer. (Or an online computer if the results are not sensitive. But if you are using the die to generate a private key, the results are sensitive, so be careful.)

This is how you use the statistical software R to test your results for bias:

  • Run R by typing R on the Terminal.
  • Type rolls = c(1,2,3,4,5,6,1,2,3,4,5,6,...,1,2,3,4,5,6) to store your hundred numbers from 1 to 6. Of course, that the previous thing (containing "...") is not valid code. You should put all of your hundred numbers in there separated with commas.
  • Type frequency = table(rolls)
  • Type chisq.test(frequency)
  • Take a look at the resulting p-value. The p-value basically tells you: What is the probability that a truly random die will produce results even more extreme than the results we're seeing? (Source.) To keep it simple: If this is higher than 0.1, there is no evidence of bias. Otherwise, there is evidence of bias.

See also my other tutorials:
Tutorial: Installing R on an offline Ubuntu computer
Tutorial: Compiling Armory and getting it onto an offline computer
Tutorial: Creating a bulletproof 255-bit entropy Armory wallet
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!