Accumulators

Accumulators

The Accumulators class enumerates the various way of combining a list of values into a single value that are used in various algorithms.

accumulate_at(indices, weights, accumulator)

Accumulate the given weights located at given indices.

class Accumulators

The Accumulators class enumerates the various way of combining a list of values into a single value that are used in various algorithms.

Members:

min

max

mean

counter

sum

prod

first

last

argmin

argmax

argmax = <Accumulators.argmax: 9>
argmin = <Accumulators.argmin: 8>
counter = <Accumulators.counter: 5>
first = <Accumulators.first: 0>
last = <Accumulators.last: 1>
max = <Accumulators.max: 4>
mean = <Accumulators.mean: 2>
min = <Accumulators.min: 3>
property name
prod = <Accumulators.prod: 7>
sum = <Accumulators.sum: 6>
accumulate_at(indices, weights, accumulator)[source]

Accumulate the given weights located at given indices.

Let \(M = max(indices)\). For all \(i \in \{0, \ldots, M\}\)

\[result[i] = accumulator(\{weights[j, :] \mid indices[j] = i \})\]
Parameters
  • indices – a 1d array of indices (entry equals to \(-1\) are ignored)

  • weights – a nd-array of shape \((s_1, \ldots, s_n)\) such that \(s_1=indices.size\)

  • accumulator – see Accumulators

Returns

a nd-array of size \((M, s_2, \ldots, s_n)\)