Well, the next step is to verify the keys of the One-Time-Pad randomly generated by Python's random method
There are many types of methods for checking if the numbers are random.
Characteristics:
- Uniformly distributed
- No numbers repeated on a specified length
- Numbers must be independent of each other
- The series should be reproducible
- The numbers must be generated quickly
Part of the previous program had to generate the random numbers
Code
In this code I generate random numbers between 0 and 1 to create different keys, now is necesary to verify that this numbers are really random
Test used "Run Test"
In this Test is verified if the hypothesis of a number is really random between two elements, in this case 0 and 1.
Parameters
amount of the first element in this case "0"
amount of the second element in this case "1"
amount of elements
amount of blocks
Regarding the blocks, a block is when the same element is repeated until meet the other element and it starts over with a new block:
For example:
In this case, we have 5 Blocks
Having this elements clearly defined, we can begin seeing how the test works
First, we get the arithmetic mean:
After we got the arithmetic mean, the variance:
Finally we got the probability of Z
Code:
Screen Printing
In this case is randomly, but in mayor of the case arenot randomly
Is randomly = 20%
Not randomly = 80 %
Test was performed 10 times
Sorry, here is more information, the value 1.96 is found in the critical value, it depends of the level of reliability, in this case 95 percent.
Graphics and table:
Here is the table:
1 - a | a/2 | Za/2 |
0.90 | 0.05 | 1.645 |
0.95 | 0.025 | 1.96 |
0.99 | 0.005 | 2.575 |
Thanks, have a nice day :D
http://www.ub.edu/aplica_infor/spss/cap5-4.htm
http://nlab.ee.tokushima-u.ac.jp/nishio/Pub-Data/CONF/C174.pdf
http://en.wikipedia.org/wiki/Wald%E2%80%93Wolfowitz_runs_test
http://webspace.ship.edu/pgmarr/Geo441/Examples/Runs%20Test.pdf
http://www.ditutor.com/inferencia_estadistica/valores_criticos.html
http://nlab.ee.tokushima-u.ac.jp/nishio/Pub-Data/CONF/C174.pdf
http://en.wikipedia.org/wiki/Wald%E2%80%93Wolfowitz_runs_test
http://webspace.ship.edu/pgmarr/Geo441/Examples/Runs%20Test.pdf
http://www.ditutor.com/inferencia_estadistica/valores_criticos.html