Saturday, October 8, 2022

Drawing Random Numbers with Playing Cards 


An Easy Way to Get Random Numbers

Need an easy and fun way to draw random is to use a playing deck of cards.  No electricity or potentially expensive electronic devices are needed, and your shuffling skills will improve dramatically.  





Take a regular deck of cards, and you will only need 40 cards.  Get all the Aces, ones through nines, and one set of face cards.   Assign the following cards as the following values:


Aces:  1

Twos:  2

Threes: 3

Fours: 4

Fives: 5

Sixes: 6

Sevens: 7

Eights: 8

Nines: 9

Any set of face card or tens: 0  (I use Jacks, see the pictures above.  You can use Queens, Kings, or Tens)


To get a random number:

1.  Shuffle the deck

2.  Draw up to four cards 

3.  That card becomes the random number.  Insert a decimal point anywhere if appropriate.  


Why only up to four cards?  There are only four digits available per deck.  We are generating a samples with no replacement.  


Sample four digit numbers:

8-clubs, Ace-hearts, 2-clubs, 5-diamonds:  8125

2-diamonds, Ace-clubs, 3-clubs, 5-spades:  2135

4-hearts, 8-spades, 3-diamonds, 9-spades: 4839

4-hearts, 3-diamonds, 9-slides, 8-clubs: 4398

Jacks-clubs, Ace-clubs, 2-diamonds, 2-spades: 0122


How many possible permutations are possible with this deck?

2 digits:  nPr(40, 2) = 1560

3 digits:  nPr(40, 3) = 59,280

4 digits:  nPr(40, 4) = 2,193,360



Can we create a program to generate random numbers using this method?  

Yes.   I am using the TI-84 Plus CE to for this program.   The TI-84 has a randIntNoRep function, which generates a list of random integers without replacement.   The nice part of the is we are working with base 10, so the use of a remainder function will give the results we want: 0 through 9.  


Syntax:


Random Sample of Integers Without Replacement:

randIntNoRep(low, high, size of the sample)


Remainder function, which can be used as the modulus function.

remainder(x, y):  returns the remainder of x ÷ y


The program RANDDECK will generate a list and draw a histogram.


TI-84 Plus CE Program:  RANDDECK





"2022-08-16 EWS"

ClrHome

Disp "MAKE A 4 DIGIT,","NUMBER FROM A DECK 0-9"

Input "NO OF TRIALS: ", N

For(I,1,N)

randIntNoRep(1,40,4)→L6

remainder(L6,10)→L6

sum(L6*{1000,100,10,1})→N

If I=1

Then

{N}→L5

Else

augment(L5,{N})→L5

End

End

Pause L5

ClrHome

Disp "PRESS [ENTER] TO"

Pause "DISPLAY HISTOGRAM"

Plot1(Histogram,L5,1,BLUE)

PlotsOn 1

ZoomStat


Here is an example.



Until next time,


Eddie


All original content copyright, © 2011-2022.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.