All problems
Expanding Origin Training Size
Problem
Compute the total number of training observations used across expanding-origin evaluations. Origins start with min_initial observations and grow one at a time; the last training set ends at n - horizon.
Return the sum of those training sizes, or 0 if none are valid. For example (6, 2, 1) sums sizes 2, 3, 4 and 5.
Hint
Sizes grow by one each origin, so this is a simple arithmetic series sum.
Test cases
case 1
in: [10,3,1]
expected: 42
case 2
in: [5,5,2]
expected: 0
case 3
in: [6,2,1]
expected: 14
case 4
in: [4,4,1]
expected: 0
Starter codePython
def expanding_origin_training_size(n, min_initial, horizon):
# Your code here
pass4 test cases · run your code against them in the editor