Description Usage Arguments Details Value Note See Also Examples
Calculates all possible combinations as result of rolling a set of dice. Similar permutations are identified under the same combination and counted as many times as many occurrencies. Thee user can choose wheter to match exact values or to perform partial matches.
1 | dice.combinations(faces, dice, rolls, weights, getPartial, getExact, toSum = FALSE)
|
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. |
getExact |
A vector containing values to be matched exactly, namely the function returns only those combinations containing all the above mentioned variables. |
getPartial |
A vector containing values to be matched partially, namely the function returns only those combinations containing at least one of the above mentioned variables. If missing, it defaults to c(1:faces), namemly the function returns all combinations. |
toSum |
A logical value, defaulting to FALSE. If TRUE, the function returns the sum of the frequencies of the matches (to be used together with getExact or getPartial) |
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.
values |
If toSum = FALSE, a list of all possible combinations rolled, together with corresponding frequencies. If toSum = TRUE, the function returns the sum of all frequencies in correspondence of matched valules. |
The case face = 2 corresponds to the coin.flip
.
Makes use of dice.roll
.
1 2 | dice.combinations(faces = 6, dice = 4, rolls = 100,
getExact = c(3,5), getPartial = c(1,2), toSum = TRUE)
|
[1] 0.11
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.