View Source Rollex.Distribution (Rollex v0.7.1)

This module provides functions to calculate various outcome distributions of sets of dice. This includes minimums, maximums, and histograms.

Link to this section Summary

Functions

Calculates the maximum value possible from a roll definition

Calculates the minimum value possible from a roll definition

Calculates the minimum and maximum value possible from a roll definition

Takes histogram, a translation magnitude, and a 3-arity functions to apply to entries in the histogram, returning a translated histogram. Useful for performing arithmetic on histograms allowing for the representation of things such as "1d8+2"

Takes two histograms and combines them into one

Link to this section Functions

Link to this function

histogram(quantity, sides, effort_count \\ 0)

View Source

Specs

histogram(
  quantity :: pos_integer(),
  sides :: pos_integer(),
  effort_count :: non_neg_integer()
) :: {map(), effort_count :: non_neg_integer()}

Specs

max(Rollex.t()) :: {:ok, number()} | {:error, reason :: String.t()}

Calculates the maximum value possible from a roll definition

Specs

min(Rollex.t()) :: {:ok, number()} | {:error, reason :: String.t()}

Calculates the minimum value possible from a roll definition

Specs

range(Rollex.t()) ::
  {:ok, min :: number(), max :: number()} | {:error, reason :: String.t()}

Calculates the minimum and maximum value possible from a roll definition

Link to this function

translate_histogram(h, magnitude, merge_op)

View Source

Specs

translate_histogram(
  h :: map(),
  magnitude :: number(),
  Rollex.Utilities.merge_operation()
) :: map()

Takes histogram, a translation magnitude, and a 3-arity functions to apply to entries in the histogram, returning a translated histogram. Useful for performing arithmetic on histograms allowing for the representation of things such as "1d8+2"

Specs

zip_histograms(left :: map(), right :: map()) :: map()

Takes two histograms and combines them into one