I would like to measure the amplitude of waves in a noisy time-series on-line. I have a time-series that models a noisy wave function, that undergoes shifts in amplitude. Say, for example, something like this:
set.seed <- 1001 x <- abs(sin(seq(from = 0, t = 100, by = 0.1))) x <- x + (runif(1001, 0, 1) / 5) x <- x * c(rep(1.0, 500), rep(2.0, 501))
The resulting data looks like this:
> head(x, n = 30)  0.1581530 0.1329728 0.3911897 0.4104984 0.4774424 0.5118123 0.6499325  0.6837706 0.8520770 0.8625692 0.8441520 0.9960601 1.1119514 1.1414032  1.1153601 1.1456799 1.0843497 1.1141201 1.1290904 0.9906415 0.9836052  0.9369836 0.9493608 0.7484588 0.7588435 0.6467422 0.5787302 0.4665009  0.4643982 0.3398427 > plot(x) > lines(x)
As you can see, the because of the noise in the series the data does not increase monotonically between the waves' troughs and crests.
I'm looking for a way to estimate the amplitude of each wave's peak on-line in a computationally untaxing way. I can probably find a way to measure the maximum magnitude of the noise term. I'm not sure if the frequency of the waves is constant, so I'd be interested both in answers that assume a constant (known) wave frequency or a variable wave frequency. The real data is also sinusoidal.
I'm sure that this is a common problem with well-known solutions, but I am so new to this that I don't even know what terms to search for. Also, apologies if this question would be more appropriate to stackoverflow, I can ask there if that is preferred.