WeightedRandom.Backend.WalkerAlias.Types (weighted_random v1.0.0-rc.1)

Copy Markdown View Source

Summary

Types

The Walker Alias method sorts n probabilities into n buckets. Every bucket has exactly 2 outcomes in it, which may or may not be duplicated. They are split on the split point.

When a bucket has two values in it, the lower value takes up the space up to, and including the split_point. the higher value takes up the remainder

Types

bucket()

@type bucket() ::
  {split_point(), lower_index :: WeightedRandom.Utils.Types.index(),
   higher_index :: WeightedRandom.Utils.Types.index()}

The Walker Alias method sorts n probabilities into n buckets. Every bucket has exactly 2 outcomes in it, which may or may not be duplicated. They are split on the split point.

For example, if a bucket has 25% outcome 1, and 75% outcome 5, then it looks like {0.25, 1, 5}

split_point()

@type split_point() :: float()

When a bucket has two values in it, the lower value takes up the space up to, and including the split_point. the higher value takes up the remainder