seldonian.utils.stats_utils.weighted_sum_gamma

weighted_sum_gamma(arr, gamma=0.9)

Calculate weighted sum of an array, where weights are gamma**(index of arr). Used in calculating sum of discounted rewards in RL

Parameters:
  • arr (Numpy ndarray) – An input array

  • gamma (float) – The constant used for weighting the array, also called the discount factor in RL

Returns:

The weighted sum

Return type:

float