0
$\begingroup$

I want to generate uniformly distributed random numbers between 1 and 26 with a dice: Is this correct:

I have assembled the following algorithm using the Monte Carlo Method:

{1, 2, 3, 4, 5, 6} {7, 8, 9, 10, 11, 12} {13, 14, 15, 16, 17, 18} {19, 20, 21, 22, 23, 24} {25, 26, 0, 0, 0, 0} {0, 0, 0, 0, 0, 0}

First step: Throw the dice. If the dice is x, I choose the x-th set.

Second step: Throw the dice. If the dice is y, I choose the y-th element of the choosen set. If the element is zero -> return to first step and repeat else -> return the chosen element as the result.

Since the two steps are independent of each other, each outcome has probability 1/36, and hence, the algorithm has equally distributed output of a number between 1 and 26.

Is this reasoning correct and if not, what should I change? Is there an even easier way?

thx :)

greetings

$\endgroup$
5
  • $\begingroup$ If "zero -> repeat" means "repeat from the first step", then yes, it is uniformly distributed in 1 to 26, since it is equivalent to rolling a "36 sided die" and re-rolling if you get 27 or higher. However, I do not see how you are going to do encryption with this, it seems that you are generating a random sequence of letters instead. $\endgroup$ Aug 1 at 12:05
  • $\begingroup$ How does this encrypt text? It looks like it just generates random numbers. $\endgroup$
    – whuber
    Aug 1 at 13:48
  • 1
    $\begingroup$ hey there, thanks for your comments, I have a given text, say: "hello", I take the h transform it into 8, then I role the dice two times to get an evenly distributed number between 1 and 26, say for example 2 and hence the encrypted letter will be 10 which is j, I will do this with all letters of the text. The result will be a sheet with the encrypted text and a sheet with the generated random numbers. If I want to decrypt I subtract the generated number on the sheet, say here 2 from the encrypted letter, say 10 and I get 10 - 2 = 8 = h $\endgroup$ Aug 1 at 14:28
  • $\begingroup$ but you are right, I will edit my question since it is not clear how I will use the above discribed algorithm to encrypt a text $\endgroup$ Aug 1 at 15:09
  • 2
    $\begingroup$ The first duplicate answers your question. The other duplicates are very closely related and include additional methods. $\endgroup$
    – whuber
    Aug 1 at 15:36