distribute_integer_randomly

negmas.helpers.distribute_integer_randomly(n, m, min_per_bin=1)[source]

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

Parameters:
  • n (int) – The integer to distribute.

  • m (int) – The number of values to distribute over.

  • min_per_bin (int | None) – 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

Return type:

list[int]

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.