Skip to content
DeepForgeby svx
All problems
MediumTime Seriests-109

TSB Method Lite

Problem

Perform one Teunter-Syntetos-Babai (TSB) update and return [probability, size, forecast]. If obs > 0 the occurrence probability becomes beta * 1 + (1 - beta) * prob and the size becomes alpha * obs + (1 - alpha) * size; otherwise the probability decays by (1 - beta) and the size is unchanged. The forecast is probability * size.

Hint

Unlike Croston, TSB updates the probability on every period, including zeros.

Test cases

case 1
in: [0.2,5,8,0.3,0.4]
expected: [0.52,5.9,3.0680000000000005]
case 2
in: [0.2,5,0,0.3,0.4]
expected: [0.12,5,0.6]
case 3
in: [0.1,2,3,0.5,0.5]
expected: [0.55,2.5,1.375]
case 4
in: [0.5,4,0,0.2,0.6]
expected: [0.2,4,0.8]
Starter codePython
def tsb_method_step(prob, size, obs, alpha, beta):
    # Your code here
    pass

4 test cases · run your code against them in the editor