Squash trends to known boundaries

class Squasher[source]

Squasher(low=None, high=None, mean=0, sd=1, alpha=0.01) :: Module

Squashes output to lie beween high and low.

Test with Dummy Data

N = 700
t = torch.arange(N)

trend = 0.05*t + 0.1
trend[t>350] = -0.1*(t[t>350] - 350) + trend[t==350]

noise = torch.randn(trend.shape)
y = trend + noise

s = Squasher(-5, 10)

plt.plot(t, y, label='observed')
plt.plot(t, trend, label='actual')
plt.plot(t, s(y), label='squashed')
plt.legend()
plt.show()