DatasetsforSimulation.Rd
For performing elementary probability calculations in introductory statistic courses, we might want to simulate random games.
The dataset roulette
contains the standard sample space for one spin on a roulette wheel.
cards
contains the standard set of 52 playing cards in four colours (without Jokers). tarot
does the same with a classic tarot deck.
cards
tarot
roulette
cards
is a data.frame
with three columns named card
, rank
and suit
tarot
is a data.frame
with four columns named card
, rank
, suit
and desc
roulette
is a data.frame
with seven columns named num
and col
, parity
, highlow
, dozens
, column
, pocketrange
head(cards)
#> card rank suit
#> 1 2-club 2 club
#> 2 3-club 3 club
#> 3 4-club 4 club
#> 4 5-club 5 club
#> 5 6-club 6 club
#> 6 7-club 7 club
head(tarot)
#> card rank suit desc
#> 1 1-wand 1 wand <NA>
#> 2 2-wand 2 wand <NA>
#> 3 3-wand 3 wand <NA>
#> 4 4-wand 4 wand <NA>
#> 5 5-wand 5 wand <NA>
#> 6 6-wand 6 wand <NA>
head(roulette)
#> num col parity highlow dozens column pocketrange
#> 1 0 green <NA> <NA> NA NA jeu zero
#> 2 26 black even high 3 35 jeu zero
#> 3 3 red odd low 1 36 jeu zero
#> 4 35 black odd high 3 35 jeu zero
#> 5 12 red even low 1 36 jeu zero
#> 6 28 black even high 3 34 voisins du zero
# drawing 5 cards
sample(cards$card, 5)
#> [1] "Q-spade" "5-club" "K-spade" "7-diamond" "J-diamond"
# drawing 5 cards with jokers
sample(c(cards$card, rep("Joker", 3)), 5)
#> [1] "9-heart" "A-club" "6-diamond" "2-spade" "K-heart"
# spin the wheel by using the DescTools::Sample() for sampling
# rows from a data frame
Sample(roulette, size=1)
#> num col parity highlow dozens column pocketrange
#> 32 2 black even low 1 35 voisins du zero
# simulate the evening in Las Vegas with 10 games
Sample(roulette, 10, replace=TRUE)
#> num col parity highlow dozens column pocketrange
#> 21 23 red odd high 2 35 tiers du cylindre
#> 20 10 black even low 1 34 tiers du cylindre
#> 30 17 black odd low 2 35 orphelins
#> 22 8 black even low 1 35 tiers du cylindre
#> 34 4 black even low 1 34 voisins du zero
#> 15 1 red odd low 1 34 orphelins
#> 26 13 black odd low 2 34 tiers du cylindre
#> 27 27 red odd high 3 36 tiers du cylindre
#> 28 6 black even low 1 36 orphelins
#> 12 31 black odd high 3 34 orphelins