Enum SelectionStrategy
Specifies the algorithm used by ProbabilityList<T> to sample entries according to their weighted probabilities.
Namespace: Scylla.Core.Util.Random
Assembly: ScyllaCore.dll
Syntax
public enum SelectionStrategy
Remarks
All three strategies produce the same statistical distribution for the same set of probabilities; the choice is purely a performance trade-off:
| Strategy | Build cost | Sample cost | Best use case |
|---|---|
| AliasTable | O(n) | O(1) | Large lists, infrequent modification |
| LinearScan | O(1) | O(n) | Small lists or frequent probability changes |
| BinarySearchCDF | O(n) | O(log n) | Medium lists, moderate pick frequency |
When any entry has an IProbabilityInfluence provider attached, the alias table and CDF are bypassed regardless of the configured strategy, and a runtime linear scan over dynamically computed effective probabilities is used instead.
Fields
| Name | Description |
|---|---|
| AliasTable | Walker's Alias Method. The internal table is built in O(n) time when entries change, and each sample is O(1) requiring exactly two uniform random values. This is the default strategy and is optimal for large lists where picks far outnumber modifications. |
| BinarySearchCDF | Binary search over a precomputed cumulative distribution function (CDF). The CDF is built in O(n) time and samples are O(log n), placing this strategy between LinearScan and AliasTable for medium-sized lists. |
| LinearScan | Linear scan through accumulated probabilities. Requires no precomputed structure (O(1) build cost) but samples in O(n) time. Best suited for small lists (typically fewer than eight entries) or for lists whose entries change frequently between picks, where the alias table rebuild cost would dominate. |