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?

  • $\begingroup$ 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. $\endgroup$ May 7 '13 at 7:39
  • 2
    $\begingroup$ 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? $\endgroup$
    – Naresh
    May 7 '13 at 9:28
  • $\begingroup$ 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 $\endgroup$
    – hassan789
    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.



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:

Slant Basis Functions

(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.

  • $\begingroup$ looks promising! $\endgroup$
    – hassan789
    May 7 '13 at 23:11
  • $\begingroup$ using this Matlab code: eeweb.poly.edu/iselesni/slantlet/index.html I will provide feedback soon... $\endgroup$
    – hassan789
    May 7 '13 at 23:29
  • $\begingroup$ I don't think the Slantlet Transform is the same thing as the Slant Transform. Both might be useful though. $\endgroup$
    – datageist
    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

  • 1
    $\begingroup$ 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 $\endgroup$
    – hassan789
    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

  • $\begingroup$ 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)? $\endgroup$
    – hassan789
    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
  • $\begingroup$ Could you explain this a bit more? I don't see how integration before the WHT will give the desired result. $\endgroup$ May 8 '13 at 11:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.