chooseBestDistribution

maelzel.distribute.chooseBestDistribution(values, possibleValues)[source]

Reconstruct the given sequence with items from possibleValues

Try to follow the distribution of values as close as possible by drawing elements from possibleValues, so that sum(chosen) is as close as possible to ``sum(values)` at any moment of the operation.

Parameters:
  • values (Sequence[TypeVar(T)]) – a seq. of values

  • possibleValues (Sequence[TypeVar(T)]) – a seq. of values to draw from

Return type:

list[TypeVar(T)]

Returns:

a “reconstruction” of the sequenve values with items drawn from possibleValues