Skip to contents

Title

Usage

cross_trials(trial = prize_wheel, num_trials = 2)

Arguments

num_trials

Examples

library(dplyr)
#> 
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#> 
#>     filter, lag
#> The following objects are masked from ‘package:base’:
#> 
#>     intersect, setdiff, setequal, union
prize_wheel |>
   mutate(prob = frequency/sum(frequency)) |>
   cross_trials(num_trials = 2)
#> # A tibble: 9 × 8
#>   t1_sector_type t1_frequency t1_payout t1_prob t2_sector_type t2_frequency
#>   <fct>                 <int>     <int>   <dbl> <fct>                 <int>
#> 1 No Prize                  9         0  0.75   No Prize                  9
#> 2 No Prize                  9         0  0.75   Win $1                    1
#> 3 No Prize                  9         0  0.75   Win $3                    2
#> 4 Win $1                    1         1  0.0833 No Prize                  9
#> 5 Win $1                    1         1  0.0833 Win $1                    1
#> 6 Win $1                    1         1  0.0833 Win $3                    2
#> 7 Win $3                    2         3  0.167  No Prize                  9
#> 8 Win $3                    2         3  0.167  Win $1                    1
#> 9 Win $3                    2         3  0.167  Win $3                    2
#> # ℹ 2 more variables: t2_payout <int>, t2_prob <dbl>

bernoulli_trial(.1) %>%
cross_trials(num_trials = 3)
#> # A tibble: 8 × 6
#>   t1_outcome t1_prob t2_outcome t2_prob t3_outcome t3_prob
#>        <int>   <dbl>      <int>   <dbl>      <int>   <dbl>
#> 1          0     0.9          0     0.9          0     0.9
#> 2          0     0.9          0     0.9          1     0.1
#> 3          0     0.9          1     0.1          0     0.9
#> 4          0     0.9          1     0.1          1     0.1
#> 5          1     0.1          0     0.9          0     0.9
#> 6          1     0.1          0     0.9          1     0.1
#> 7          1     0.1          1     0.1          0     0.9
#> 8          1     0.1          1     0.1          1     0.1