getTotalProbs              package:dice              R Documentation

_C_a_l_c_u_l_a_t_e _t_h_e _p_r_o_b_a_b_i_l_i_t_i_e_s _o_f _a_l_l _p_o_s_s_i_b_l_e _o_u_t_c_o_m_e _t_o_t_a_l_s _o_f _a _d_i_c_e _r_o_l_l

_D_e_s_c_r_i_p_t_i_o_n:

     For a specified number of dice with a specified number of sides
     per die (and dropping a specified number of dice-those with the
     lowest values), 'getTotalProbs' calculates the probabilities of
     all possible outcome totals (i.e., all possible sums of those dice
     whose results are not dropped); the function also accommodates
     modifiers (either to each die roll or to the sum), such as rolling
     five four-sided dice and adding 1 to the outcome of each roll, or
     rolling one twenty-sided die and adding 12 to the outcome.  (Such
     modified rolls frequently occur in the context of role-playing
     games, e.g., Dungeons & Dragons, Mutants & Masterminds, or BESM.)

_U_s_a_g_e:

     getTotalProbs(ndice, nsides, nkept = ndice, totalModifier = 0, perDieModifier = 0, perDieMinOfOne = TRUE)

_A_r_g_u_m_e_n_t_s:

   ndice: A single positive integer representing the number of dice to
          roll 

  nsides: A single positive integer representing the number of sides on
          each die ('getTotalProbs''s dice-rolling process involves
          only one type of die per call) 

   nkept: A single positive integer representing the number of dice
          whose values to include when calculating the total (the dice
          to be kept will always be those with the *highest* values) 

totalModifier: A single integer representing an amount to add to or
          subtract from the outcome total 

perDieModifier: A single integer representing an amount to add to or
          subtract from each die roll 

perDieMinOfOne: A logical flag indicating whether each die roll should
          be considered to have a minimum value of 1 (as is often true
          in role-playing game contexts) 

_V_a_l_u_e:

probabilities : A matrix with a row for each possible outcome total and
          three columns: one that lists each total, one for the
          probability of that total, and one for the number of ways to
          roll that total

average : A single number representing the expected value of the
          specified dice-rolling process

_A_u_t_h_o_r(_s):

     Dylan Arena

_R_e_f_e_r_e_n_c_e_s:

     This function's implementation originated with the ideas presented
     in the following forum thread: 

     <URL: http://www.enworld.org/showthread.php?t=56352&page=1&pp=40>

_E_x_a_m_p_l_e_s:

     #

     ## Rolling four six-sided dice and keeping the three highest die rolls

     getTotalProbs(ndice = 4,
                   nsides = 6,
                   nkept = 3)

     ## Rolling five four-sided dice and adding 1 to each die roll

     getTotalProbs(ndice = 5,
                   nsides = 4,
                   perDieModifier = 1)

     ## Rolling one twenty-sided die and adding 12 to the result

     getTotalProbs(ndice = 1,
                   nsides = 20,
                   totalModifier = 12)

