1

I have a univariate time series that consists of discretely sampled (equally spaced) points of a sinusoid.

If you have a window that slides over these points (like this animation) with a length of 1/4th the period of the sinusoid (the red dots in the animation), can you do a calculation on the points in that window of which the outcome will remain constant as the window slides from left to right over the wave? And only for a window length of 1/4th the period, not for different window lengths?

Maybe it is related to the fact that a sinusoid consists of 4 equal segments that are mirrored horizontally and/or vertically to form the shape of the wave?

MisterH
  • 357

2 Answers2

0

You can certainly precompute a table of values of $\sin x$ over the range $[0,\frac \pi 2]$ at any desired spacing, then reference the table to get the value. Depending on your computer, that may be much faster. As long as the window starts at a multiple of $\frac \pi 2$, you can just read off the array in the correct direction and multiply by $-1$ when needed. If you have enough memory, you can compute the table over $[0,2\pi]$ and save some more work.

Ross Millikan
  • 383,099
0

I believe what you are asking for is a filter $\mathbf{h}$ and modulation $\mathbf{y}$ such that $(\mathbf{x} \circ \mathbf{y}) \ast \mathbf{h} = c \mathbf{1}$, where $c$ is a constant and $\mathbf{1}$ is a vector of all $1$'s. The $\ast$ operator is convolution and $\circ$ is modulation (aka Hadamard/Schur product).

The signal is of the form, $\cos( 2\pi f_0 n / f_s + \phi)$, where $f_0$ is the frequency of the wave, $f_s$ is the sampling frequency, $\phi$ is some phase offset, and $n=0,1,\dots$. Since the length of the filter is $1/4$ of the period of the signal, we know that $4N_{filt}/f_s=1/f_0$, or that $4N_{filt}f_0 = f_s$. Also, the value of $\phi$ is unimportant since it does not change sample-to-sample, so we can assume it's zero.

There are three ways to get a constant value out of the filter/modulation. The first is to remove all energy in the signal. The second is to shift all of the signal's energy to DC. The third is shift some of the energy to DC and remove the rest.

To accomplish the first of these, all you have to do is let $\mathbf{y}=\mathbf{1}$ and design $\mathbf{h}$ such that all the energy at the frequency $f_s/(4N_{filt})$ is removed. This could be done with a highpass, lowpasss, or a notch filter, though I think it will be easiest in this case to use a highpass since the frequency of interest is close to DC.

The second method of shifting all the energy to DC is not doable in this case -- at least with a linear process. The magnitude of the spectrum of the input signal is of the form $\delta(f - fs/(4N_{filt})) + \delta(f + fs/(4N_{filt}))$. Any modulation that put one of these spikes at DC would shift the other to $\delta(f \pm fs/(2N_{filt}))$.

The third method is to shift one of the spikes in the spectrum down to DC and then just filter out the other one with a lowpass filter. The shift could be accomplished with $\mathbf{y} = e^{j2\pi n / (4N_{filt})}$ and the cutoff frequency of the filter would then need to be $f_s / (2N_{filt})$ or lower.

  • AnonSubmitter85, thanks for the feedback. I guess I have some tutorials to read. Actually I was hoping that there would be a very simple mathematical (non signal-processing) calcualtion but I guess that is not the case? – MisterH Feb 14 '14 at 15:27
  • It depends on what you consider simple. Discrete convolution is nothing more than multiplying your window of samples by some constant values, summing the result, and then moving your window one sample over and repeating the process. It's straightforward really. Getting your ahead around what's going on theoretically takes some time though. – AnonSubmitter85 Feb 15 '14 at 01:16