Description Usage Arguments Details Value Examples
Simulates rolling of a set of dice.
1 |
faces |
The number of faces the dice have; if unspecified, it defaults to 6. |
dice |
The number of dice to roll; if unspecified, it defaults to 2. |
rolls |
The number of times to roll the die; if unspeciefid, it defaults to 5. |
weights |
A vector of probability weights to assign to each face of the die; if unspecified, it defaults to a fair die with weights 1/N. If specified, its lenght must obviously be equals to the number of faces and all the single weights must sum up to 1. |
The function returns an object of class diceRoll, namely a list whose values are themselves data.table
objects, in turn, so that one can directly apply any data.table
function thereupon.
results |
The numerical results rolled. |
frequencies |
A table containing each single occurrency (permutation) of results and the corresponding frequencies. |
sums_freq |
A table containing the frequencies of the sums of the values obtained in each single roll by all the dice. A cumulative sum is provided too. |
exp_value_sum |
The expectation value of the sum of the values obtained. |
1 | dice.roll(faces = 6, dice = 3, rolls = 5)
|
Call:
dice.roll(faces = 6, dice = 3, rolls = 5)
Results after 5 rolls of 3 dice:
die_1 die_2 die_3
1: 2 2 4
2: 2 5 4
3: 1 3 6
4: 5 4 5
5: 4 5 2
Frequency table for each occurrency:
die_1 die_2 die_3 N freq
1: 4 5 2 1 0.2
2: 2 2 4 1 0.2
3: 2 5 4 1 0.2
4: 5 4 5 1 0.2
5: 1 3 6 1 0.2
Frequency table of the sums:
sum N freq cum_sum
1: 8 1 0.2 0.2
2: 10 1 0.2 0.4
3: 11 2 0.4 0.8
4: 14 1 0.2 1.0
Expectation value: 10.8
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.