Talk:Deconvolution/2D+: Difference between revisions
Content added Content deleted
m (→general: signed) |
m (link fixed) |
||
Line 1: | Line 1: | ||
I got interested in higher dimensional deconvolution when contacted by someone about using it as a way of looking for trading indicators in financial time series. I set this task as an example of something that I'm speculating can be done well with functional and array processing languages, but only with difficulty otherwise, which I hope someone will weigh in to confirm or refute. In case anyone wants to know, consistent test data were generated partly by this higher dimensional convolution function, |
I got interested in higher dimensional deconvolution when contacted by someone about using it as a way of looking for trading indicators in financial time series. I set this task as an example of something that I'm speculating can be done well with functional and array processing languages, but only with difficulty otherwise, which I hope someone will weigh in to confirm or refute. In case anyone wants to know, consistent [[http://www.filedropper.com/tdat test data]] were generated partly by this higher dimensional convolution function, |
||
<lang Ursala>conv = +^|(~&x+,*DrlDSNiCK9xxSNiCK9K7iFS+ *)=>times+ **+ *K7|\x+ iota; * ! plus:-0</lang> |
<lang Ursala>conv = +^|(~&x+,*DrlDSNiCK9xxSNiCK9K7iFS+ *)=>times+ **+ *K7|\x+ iota; * ! plus:-0</lang> |
||
invoked as <code>(conv d)(h,f)</code> with dimension <code>d > 0</code> and conforming <code>h</code> and <code>f</code>. (This function essentially subsumes the [[Image convolution]] task as a special case with <code>d = 2</code> and <code>|h| = 3</code>.) I suggest a development methodology based on warming up with [[Deconvolution/1D]], then hand coding the solutions for the next few dimensions, and then looking for the pattern. |
invoked as <code>(conv d)(h,f)</code> with dimension <code>d > 0</code> and conforming <code>h</code> and <code>f</code>. (This function essentially subsumes the [[Image convolution]] task as a special case with <code>d = 2</code> and <code>|h| = 3</code>.) I suggest a development methodology based on warming up with [[Deconvolution/1D]], then hand coding the solutions for the next few dimensions, and then looking for the pattern. |
||
Line 43: | Line 43: | ||
odd number). If the solver precludes over determined systems |
odd number). If the solver precludes over determined systems |
||
and the language also doesn't let you delete rows from matrices, you might |
and the language also doesn't let you delete rows from matrices, you might |
||
have to write the code in the band function to build it that way in |
have to write the code in the <code>band</code> function to build it that way in |
||
the first place. |
the first place. |
||
Line 52: | Line 52: | ||
the <code>band</code> function above to construct a matrix <math>A</math> of vectors following |
the <code>band</code> function above to construct a matrix <math>A</math> of vectors following |
||
the same pattern, with which each <math>i,j</math>-th element of <math>A</math> being either a |
the same pattern, with which each <math>i,j</math>-th element of <math>A</math> being either a |
||
vector from <math>f</math>, or a zero vector of conforming length. |
vector from <math>f</math>, or a zero vector of conforming length. |
||
done, but I'm not sure how |
|||
pruning the matrix generalizes to higher dimensions, so the rest of |
I'm not saying it can't be done, but I'm not sure how pruning the matrix generalizes to higher dimensions, so the rest of this description assumes the solver copes with over determined systems. Such a solver is readily available in the [[http://www.netlib.org/lapack Lapack]] library, which is callable from many languages. |
||
this description assumes the solver copes with over determined |
|||
systems. Such a solver is readily available in the [[http://www.netlib.org/lapack Lapack]] library, |
|||
which is callable from many languages. |
|||
Next, pair up each row of the matrix-of-vectors <math>A</math> with the corresponding member of |
Next, pair up each row of the matrix-of-vectors <math>A</math> with the corresponding member of |
||
<math>g</math>. Since <math>A</math> is a matrix of vectors, each row of it can be considered a matrix |
<math>g</math>. Since <math>A</math> is a matrix of vectors, each row of it can be considered a matrix |
||
of scalars on its own. For each <math>i</math> ranging from 0 to <math>|g|-1</math>, the pair <math>(g_i,A_i)</math> of the <math>i</math>-th member of <math>g</math> and the <math>i</math>-th row of <math>A</math> will consist of a vector <math>g_i</math> and a matrix <math>A_{i}</math>. Pair up a copy of <math>g_i</math> with each row of <math>A_{i}</math> and apply the 1 dimensional <code>band</code> function to each member of the list of all such pairs. This step will yield a list of matrices (of scalars) each with <math>|g_i|</math> rows. Flatten this list of matrices into a single matrix with <math>|g_i|</math> rows by concatenating them row-wise (i.e., horizontally). Having done so for all <math>(g_i,A_i)</math> pairs, flatten the resulting list of <math>|g|</math> matrices into a one large matrix having <math>|g|*|g_0|</math> rows by concatenating them column-wise (i.e., vertically). This matrix should then be fed to the linear equation solver along with a flattened copy of <math>g</math>. |
|||
of scalars on its own. For each i ranging from 0 to <math>|g|-1</math>, the pair <math>(g_i,A_i)</math> |
|||
of the <math>i</math>-th member of <math>g</math> and the <math>i</math>-th row of <math>A</math> will |
|||
consist of a vector <math>g_i</math> and a matrix <math>A_{i}</math>. Pair up a copy of <math>g_i</math> with each row of <math>A_{i}</math> and apply the 1 dimensional <code>band</code> function to each member |
|||
of the list of all such pairs. This step will yield a list of matrices (of |
|||
scalars) each with <math>|g_i|</math> rows. Flatten this list of matrices into a |
|||
single matrix with <math>|g_i|</math> rows by concatenating them row-wise (i.e., |
|||
horizontally). Having done so for all <math>(g_i,A_i)</math> pairs, flatten the |
|||
resulting list of <math>|g|</math> matrices into a one large matrix having <math>|g|*|g_0|</math> rows by concatenating them column-wise (i.e., vertically). This matrix |
|||
should then be fed to the linear equation solver along with a |
|||
flattened copy of <math>g</math>. |
|||
The result returned by the linear equation solver will be a list of |
The result returned by the linear equation solver will be a list of |