PDL::Stats::Basic has a cov_table() function that operates on a matrix (assuming it has piddle dimension [observation x variable] ). Calling cov_table() on such a matrix will give back the covariance table for the variables. Is that what you are looking for?
http://pdl-stats.sourceforge.net/Basic.htm#cov_table Best, Maggie On Thu, Dec 22, 2011 at 1:16 PM, Derek Lamb <[email protected]> wrote: > Hi Zev, > > If I understand correctly, you want to do something like: > > p $a > > [ > [1 2 3 4 5] > [2 3 4 1 5] > [1 2 3 4 5] > [2 3 4 1 5] > ] > > and get out: > > p $b > > [ > [1 0 1 0] > [0 1 0 1] > [1 0 1 0] > [0 1 0 1] > ] > > where $a is an M X N piddle and $b is N X N composed of zeroes and ones, > diagonal filled with ones, and symmetric about the diagonal? I guess the > diagonal of zeroes does the comparison of a given row with itself, which > you state you don't want, but which would probably be more difficult to NOT > do than to do and just ignore if you don't want it. If that's not what you > want, you need to be more specific--this is probably going to involve > temporarily increasing the dimensionality of your input piddle and using > the threading engine to collapse it back down in a novel way, which can be > complicated. > > Derek > > > On Dec 22, 2011, at 9:39 AM, zev wrote: > > > Greetings I have a piddle (in matrix form). For each row I need a > pairwise comparison to every other row (but not to itself). I need to use > 'where' on the two piddles. I am subsequently using 'cov' in > PDL::Stats::Basic to calculate the covariance of the two piddles. > > > > Here is my questions: > > > > How can I avoid an outer and inner for loop in perl to do every pairwise > comparison? I understand this is probably a basic question, but I haven't > had luck after reading the indexing tutorial... > > > > > > -- > > Zev Kronenberg > > Graduate Student > > University of Utah > > phone: 208-629-6224 > > > > _______________________________________________ > > Perldl mailing list > > [email protected] > > http://mailman.jach.hawaii.edu/mailman/listinfo/perldl > > > _______________________________________________ > Perldl mailing list > [email protected] > http://mailman.jach.hawaii.edu/mailman/listinfo/perldl >
_______________________________________________ Perldl mailing list [email protected] http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
