knitr::opts_chunk$set(echo = TRUE) library(ggplot2)
Besides alea
other packages related to casting dice are available. In case you are looking for functionality which is not provided by alea
, this list gives you an overview over the packages I found and the description they provided:
This document shows a few of the use cases where another package might be more suitable for you.
library(dice)
The package dice
is a package for calculating probabilities of various dice-rolling events, so this is something completely different from what alea
is doing. The package consists of two functions: (a) getEventProb()
and (b) getSumProbs()
. The package is not very well documented and the functionality of getEventProb()
was not immediately clear to me. So I try to explain it in more detail.
The first three examples are taken from the manual of the package.
getEventProb(nrolls = 6, ndicePerRoll = 1, nsidesPerDie = 4, eventList = list(4, 3, c(1,2)), orderMatters = FALSE)
getEventProb(nrolls = 3, ndicePerRoll = 2, nsidesPerDie = 6, eventList = list(10, 4, c(2:6, 8:12)), orderMatters = TRUE)
The function getSumProbs()
is more straightforward.
getSumProbs(ndicePerRoll = 5, nsidesPerDie = 6, nkept = 3, dropLowest = TRUE)
For better understanding, let me compute the probabilities of a more commonly used example (e.g., for teaching). Casting a 6-sided dice for two times.
probs <- getSumProbs(ndicePerRoll = 2, nsidesPerDie = 6, nkept = 2) probs <- data.frame(probs$probabilities) ggplot(probs) + geom_col(aes(x=Sum, y=Ways.to.Roll)) + scale_x_discrete(limits=probs$Sum)
The package Rdice
contains a set of function that can do similar things as alea
.
library(Rdice)
The core function seems to be dice.roll()
. It produced a lot of output in a complicated list structure which does not make it very useful for other applications.
The following example is taken from the help page of the function an casts 3 6-sided dice 5 times each.
dice.roll(faces = 6, dice = 3, rolls = 5)
The package also contains three datasets of non-transitive dice, i.e. Efron dice (efron
), Miwin dice (miwin
) and Oskar (oskar
).
The package contains a vignette with more detailed explanations.
The package diceSyntax
contains several functions but only documentation for roll
.
The package is only available on github.
devtools::install_github("oganm/diceSyntax")
library(diceSyntax)
The interesting part of this package is that you can pass dice events like 4d6
in order to cast 4 6-sided dice.
roll("4d6")
More examples (e.g., keep highest/lowest 3, ...) can be found in the README of diceSyntax.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.