On Dec 23, 2011 8:57 AM, "Maggie X" <[email protected]> wrote:
>
> How about this
>
> pdl> p $p
>
>
> [
>  [1 0 3 0]
>  [0 1 0 1]
>  [1 3 1 3]
>  [0 1 0 1]
> ]
>
> pdl> $p->where($p >= 3) .= -999
>
> pdl> p $p
>
> [
>  [   1    0 -999    0]
>  [   0    1    0    1]
>  [   1 -999    1 -999]
>  [   0    1    0    1]
> ]
>
> pdl> $p->badflag(1);
>
> pdl> $p = $p->setvaltobad(-999);

Better yet:

pdl> $p->badflag(1);
pdl> $p = $p->setbadif($p > 3);

:)

>
> pdl> p $p
>
> [
>  [  1   0 BAD   0]
>  [  0   1   0   1]
>  [  1 BAD   1 BAD]
>  [  0   1   0   1]
> ]
>
> pdl> p $p->cov_table;
>
> [
>  [ 0.22222222 -0.22222222         BAD -0.22222222]
>  [-0.22222222        0.25           0        0.25]
>  [        BAD           0           0           0]
>  [-0.22222222        0.25           0        0.25]
> ]
>
>
> On Fri, Dec 23, 2011 at 12:59 AM, zev <[email protected]> wrote:
>>
>> Yes! that is what I am trying to do and yes those are the loops i am
trying to avoid.
>>
>> Just to prove that I am not begging for free labor here the loop I just
finished writing.  It is in a perl script not the pdl shell.
>>
>>     my $n_row =  $piddle->slice('0,:')->nelem;
>>
>>     for (my $i = 0; $i <= $n_row - 1; $i++){
>>         my $loc_a = $piddle->PDL::slice(":,$i");
>>         for (my $j = 0; $j <= $n_row -1; $j++){
>>             my $loc_b = $piddle->PDL::slice(":,$j");
>>             my ($sub_a, $sub_b) = where($loc_a, $loc_b, $loc_a < 3 &
$loc_b <3);
>>             my $cov =  $sub_a->cov($sub_b)->at;
>>             $r_data{$i}{$j} = $cov;
>>         }
>>     }
>>
>>
>> On Thu, Dec 22, 2011 at 10:26 PM, Derek Lamb <[email protected]>
wrote:
>>>
>>> ugh, not really.  (also make sure to cc the list on your replies).  Too
many $b's floating around, and no clue what $a is in your concept function.
I think it is one of your slices there?  How about this:
>>>
>>> pdl> use PDL::Stats
>>> pdl> p $input
>>>
>>> [
>>>  [1 0 3 0]
>>>  [0 1 0 1]
>>>  [1 3 1 3]
>>>  [0 1 0 1]
>>> ]
>>>
>>> pdl> for $i(0..$input->dim(1)-1){
>>>   $y = $input(:,($i));
>>> for $j(0..$input->dim(1)-1){
>>> $z = $input(:,($j));
>>> ($a,$b) = where($y,$z,($y<3) & ($z<3));
>>>   $c = cov($a,$b);
>>> print "$i, $j: $c\n";
>>> }
>>> }
>>> 0, 0: 0.222222222222222
>>> 0, 1: -0.222222222222222
>>> 0, 2: 0
>>> 0, 3: -0.222222222222222
>>> 1, 0: -0.222222222222222
>>> 1, 1: 0.25
>>> 1, 2: 0
>>> 1, 3: 0.25
>>> 2, 0: 0
>>> 2, 1: 0
>>> 2, 2: 0
>>> 2, 3: 0
>>> 3, 0: -0.222222222222222
>>> 3, 1: 0.25
>>> 3, 2: 0
>>> 3, 3: 0.25
>>>
>>> Is that what you are trying to get, but without the two for loops?
>>>
>>> Derek
>>>
>>>
>>> On Dec 22, 2011, at 11:34 AM, zev wrote:
>>>
>>>> http://stackoverflow.com/questions/8595244/pdl-pairwise-row-comparison
>>>>
>>>> On Thu, Dec 22, 2011 at 11:30 AM, zev <[email protected]> wrote:
>>>>>
>>>>> Thank you for your help.
>>>>>
>>>>>
>>>>> Here is some sudo code that will (hopeful) illustrate my point better.
>>>>>
>>>>> p $b
>>>>>
>>>>> [
>>>>>  [1 0 3 0]
>>>>>  [0 1 0 1]
>>>>>  [1 3 1 3]   <- example piddle y
>>>>>  [0 1 0 1]   <- example piddle z
>>>>> ]
>>>>>
>>>>> my concept function{
>>>>>
>>>>>
>>>>> slice $b (grab row z) - works fine
>>>>> slice $b (grab row y) - works fine
>>>>>
>>>>>
>>>>> ($a, $b) = where($a,$b, $a < 3 && $b < 3 ) - works fine
>>>>>
>>>>> p $a [1 1]
>>>>> p $b [0  0]
>>>>>
>>>>> cov($a $b) - works just fine.
>>>>>
>>>>> }
>>>>>
>>>>> I just need a way to execute pairwise across all rows.  I will need
to do factorial(n rows) comparisons.
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Zev Kronenberg
>>>> Graduate Student
>>>> University of Utah
>>>> phone: 208-629-6224
>>>>
>>>
>>
>>
>>
>> --
>> 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

Reply via email to