dice.roll {Rdice} | R Documentation |
Dice simulator
Description
Simulates rolling of a set of dice.
Usage
dice.roll(faces, dice, rolls, weights)
Arguments
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 |
Details
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.
Value
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. |
Examples
dice.roll(faces = 6, dice = 3, rolls = 5)