distribute_integer_randomly

negmas.helpers.distribute_integer_randomly(n: int, m: int, min_per_bin: int | None = 1) list[int][source]

Distributes an integer n over a list of m values randomly, with each value at least one.

Parameters:
  • n – The integer to distribute.

  • m – The number of values to distribute over.

  • min_per_bin – Minimum number of elements per bin. This is only guaranteed if n >= m * min_per_bin. If None, then the distribution will be as normal as possible

Returns:

A list of m integers, where each value is at least one.

Remarks:
  • if n < m * min_per_bin, n will be distributed randomly with some zeros inserted.