# DFT-like transform using triangle waves instead of sin waves

We know that DFT (discrete Fourier transform) breaks down a signal into multiple frequencies of sine waves. Does there exist a transform that does the same thing, but for triangle waves?

For my purposes, im only talking about 1-d signals (like voltages, etc). I'm studying historical stock market data, and I just want to look at reversals in certain stocks. In other words, I want to perform a "low-pass" on the stock price using this transform.

Edit: If yes, how can I do it?

• For any signal, I don't think so, but would love to see a proof why not. If you know the signal is composed of triangle waves then might be possible to work out their individual frequency, phase and amplitude. May 7 '13 at 7:39
• Simple reasoning says that it should be possible for any signal. Since triangles themselves can be represented by sine signals of differing frequencies and can be scaled. The real question is what would you infer from it and would such inferences be practically useful? May 7 '13 at 9:28
• Well, i'm studying historical stock market data, and I just want to look at reversals in certain stocks. In other words, I want to perform a "low-pass" on the stock price using this transform May 7 '13 at 12:49

The answer to this question is yes. There exist a fast triangle transform, FTT, for triangle waves which has a complexity of $$N\log_2(N)$$, where $$N$$ is the number of elements. It works the same like FFT and DFT, and it uses complex vectors, which means it will give you phase information for each triangle wave as well! Please have a look at the C-code function, mbin_ftt_fwd_cf() here.

--HPS

The closest orthogonal transform I know of that might meet your needs is the Slant Transform. It's based on sawtooth(ish) waves, but some of the basis functions do resemble triangle waves:

(source: Applied Fourier transform)

It was developed for image coding/compression, but it seems like a reasonable first approach for the analysis of long-term linear trends/reversals in financial data. It doesn't seem like many of the key papers describing the transform are available [for free] online, but the following paper probably has sufficient detail to implement something:

A Truncation Method for Computing Slant Transforms with Applications to Image Processing. M. M. Anguh, R. R. Martin. IEEE Trans. Communications 43 (6), 2103-2110, 1995. (author link) (pdf link)

Specifically, see Section III which gives the recursion relations used to construct the transform matrix.

• looks promising! May 7 '13 at 23:11
• using this Matlab code: eeweb.poly.edu/iselesni/slantlet/index.html I will provide feedback soon... May 7 '13 at 23:29
• I don't think the Slantlet Transform is the same thing as the Slant Transform. Both might be useful though. May 8 '13 at 0:13

First order B-splines are triangles, and there exist algorithms to represent an arbitrary signal as a sum of B-splines. As mentioned, these splines do not form an orthobasis, but this is not necessarily a terrible thing.

A good place to start is the the paper by Unser on efficient B-spline approximation. http://bigwww.epfl.ch/publications/unser9301.pdf

• this is a good start, and actually might be better for me, especially if I can use parabolic b-splines instead of cubic ones.... will read/learn more into this as well May 7 '13 at 23:17

You can do a transform that uses triangle waves instead of sine waves, but it is not a good choice because they are not orthogonal. Orthogonality is an important property of transform vectors.

Properties of Orthogonal Transforms

Orthogonal Transformation

• hmmm... im not as advanced when it comes to orthogonality... Honestly, I don't understand what the implication of orthogonality is. Does it ultimately mean that it takes more CPU cyles to do the transform (full transform kernel vs sparse transform kernel)? May 7 '13 at 23:14

You could use the adjoint of the integrator operator (i.e. cumsum) followed by a Fast Walsh-Hadamard transform.

e.g. in Matlab

n = 16;
H = fwht(eye(n))*sqrt(n); % Walsh-Hadamrd in full unitary matrix form
S = cumsum(eye(n)); % the integrator in full matrix form
T = H*S';  % cumsum along the rows of the W-H


The sections of constant positive values in H integrate to cause inclines in the sawtooth waves; negative values become decline.

T is not unitary which has repercussions for dimensional stretching. On the bright side, it does have a fast inverse: another fwht followed by a differentiator.

D = inv(S');  % difference matrix with an extra row at bottom for full rank
Tinv = D*H;   % inverse of T

• Could you explain this a bit more? I don't see how integration before the WHT will give the desired result. May 8 '13 at 11:45