// Generates the weights array for a set of taps. The returned weights use 1.0 as a base value,
// with the weights of the taps in ieach discounted row being multiplied by (1.0 - forgetting).
Generates the weights array for a set of taps. The returned weights use 1.0 as a base value,
with the weights of the taps in ieach discounted row being multiplied by (1.0 - forgetting).
// Generates the weights array for a set of taps . The returned weights use 1 . 0 as a base value // with the weights of the taps in ieach discounted row being multiplied by ( 1 . 0 - forgetting ) .
func weights(taps [][]time.Duration, forgetting float64) []float64 {
	N := 0
	for _, row := range taps {
		N += len(row)
	}
	array := make([]float64, N)
	switch {
	case forgetting == 0.0:
		for i := range array {
			array[i] = 1.0
		}
	case forgetting > 0.0:
		ix := len(array) - 1
		w := 1.0
		f := 1.0 - forgetting
		for _, row := range taps {
			for range row {
				array[ix] = w
				ix--
			}
			w = w * f
		}
	case forgetting < 0.0:
		ix := 0
		w := 1.0
		f := 1.0 + forgetting
		for _, row := range taps {
			for range row {
				array[ix] = w
				ix++
			}
			w = w * f
		}
	}
	return array
}
func weights ( taps [ ] [ ] time . Duration , forgetting float64 ) [ ] float64 { N := 0 for _ , row := range taps { N += len ( row ) } array := make ( [ ] float64 , N ) switch { case forgetting == 0.0 : for i := range array { array [ i ] = 1.0 } case forgetting > 0.0 : ix := len ( array ) - 1 w := 1.0 f := 1.0 - forgetting for _ , row := range taps { for range row { array [ ix ] = w ix -- } w = w * f } case forgetting < 0.0 : ix := 0 w := 1.0 f := 1.0 + forgetting for _ , row := range taps { for range row { array [ ix ] = w ix ++ } w = w * f } } return array }
Generates the weights array for a set of taps.
Generates the weights array for a set of taps .