Working off from a question I asked previosuly where the answer to my problem was to use ListCorrelate, I have been playing around with trying to use ListCorrelate again, but this time for 3, two dimensional grids. By this I mean the following:

Take an array

array = Developer`ToPackedArray @ RandomChoice[{-1, 1}, {100, 100}];

the code

count[dim_] := Outer[
Join[Range[dim], Reverse[Range[dim-1]]],
Join[Range[dim], Reverse[Range[dim-1]]]

r2 = ListCorrelate[array, array, {-1, 1}, 0] / count[100] //Transpose;

with some manipulating of the output gives you all two point correlation of the array. To do this we need to enter two 2D arrays. What I want to do now is to work out all triangular correlations on array. Hence I would need to somehow enter three array parameters into ListCorrelate - of which I cannot do. I have looked at the working of ListCorrelate which can be found here in a another question. I have fiddled around, and can't seem to get anywhere. The only was I can think of is to do the following:

r2 = ListCorrelate[array, array, {-1, 1}, 0] / count[100] //Transpose;
r3 = ListCorrelate[array, array, {-1, 1}, 0] / count[100] //Transpose;
r23 = ListCorrelate[r2, r3, {-1, 1}, 0] / count[200] //Transpose;

count here works out the average of each correlation - see my previous question for better background -. The problem here is that I do not think that r23 is the triangular (or three point) correlations of array. Diagrammatically this is what I would like ListCorrelate to do:enter image description here

In the normal use of ListCorrelate you would only have the red and green boxes. I now want to add the blue box. Essentially this translates to:

enter image description here

moving the green triangle to the different positions. This is naturally only one of the possible box selections or triangle positioning as well as orientations. In my pictures I haven't been very thorough as ListCorrelate makes use of a Kernal, the link to the explanation of how ListCorrelates explains in much greater clarity. My purpose was to give an understanding of how I would like to implement ListCorrelate to calculate all triangular correlations on array, just as the normal use of it, is able to calculate all linear(or two point) correlations on array.


Your Answer

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

Browse other questions tagged or ask your own question.