rroll: Generates a vector of random die rolls

View source: R/SDS100_generate_simulated_samples.R

rrollR Documentation

Generates a vector of random die rolls

Description

This function simulates rolling a k-sided die n times and returns the number of times each of the k outcomes occured, where the probability of the k outcomes is given by the vector prob. This function is just a wrapper for the 'rmultinom()' function.

Usage

rroll(num_rolls, prob = rep(1/6, 6), outcome_names = NULL)

Arguments

num_rolls

The number of times to roll the die.

prob

The probability of getting each side of the die on each roll

outcome_names

A vector of names for the outcomes. Default values is of NULL returns sequential integers as the names of the vector.

Examples

 set.seed(100)
 # roll a 6-sided fair die (the default) 100 times
 rroll(100, outcome_names = c("one", "two", "three", "four", "five", "six"))


emeyers/SDS100 documentation built on April 28, 2024, 5:07 p.m.