# Signal that transitions from seasonal to non-seasonal
t <- seq(0, 20, length.out = 400)
X <- ifelse(t < 10, sin(2 * pi * t / 2), rnorm(sum(t >= 10), sd = 0.3))
X <- matrix(X, nrow = 1)
fd <- fdata(X, argvals = t)
# Detect changes with Otsu threshold
changes <- detect.seasonality.changes.auto(fd, period = 2)
print(changes$computed_threshold)
Run the code above in your browser using DataLab