WeightedRandom.Utils.Types (weighted_random v1.0.0-rc.1)

Copy Markdown View Source

Summary

Types

Anything compatible with Curves.define_bezier/2.

A list of probabilities

See function docs for details.

The values to be randomly picked from.

A list of floats, representing percentages, that should add up to 1.0

A float between 0.0, and 1.0

Due to floating point precision problems, we must allow a certain amount of incorrectness. Usually this is a very small number like 1.0e-10 (i.e. 0.0000000001)

The weight, as given by the end user, which will influence the randomization.

Types

curve_spec()

@type curve_spec() :: atom() | [{number(), number()}]

Anything compatible with Curves.define_bezier/2.

index()

@type index() :: pos_integer()

indexed_probabilities()

@type indexed_probabilities() :: [indexed_probability()]

A list of probabilities

indexed_probability()

@type indexed_probability() :: {probability(), index()}

opts()

@type opts() :: keyword()

See function docs for details.

outcomes()

@type outcomes() :: [...] | Range.t()

The values to be randomly picked from.

probabilities()

@type probabilities() :: [probability()]

A list of floats, representing percentages, that should add up to 1.0

probability()

@type probability() :: float()

A float between 0.0, and 1.0

tolerance()

@type tolerance() :: float()

Due to floating point precision problems, we must allow a certain amount of incorrectness. Usually this is a very small number like 1.0e-10 (i.e. 0.0000000001)

weight_spec()

@type weight_spec() :: %{
  :target => any(),
  required(:amount | :weight) => number(),
  optional(:left_dist) => integer(),
  optional(:right_dist) => integer(),
  optional(:radius) => integer(),
  optional(:curve) => curve_spec()
}

The weight, as given by the end user, which will influence the randomization.