in reply to Comparing graph shapes or soft matching.
EDIT: If you are expecting all lists to be similar to some global target, you could calculate the count means of each value over all sets. Then instead of comparing two sets (as above), you could compare each set to the means.foreach $value (@listA) { $countsA{$value}++; $seen{$value} = 1; } foreach $value (@listB) { $countsB{$value}++; $seen{$value} = 1; } $diff = 0; foreach $value (keys %seen) { if( not defined $listA{$value} ) { $listA{$value} = 0; } elsif( not defined $listB{$value} ) { $listB{$value} = 0; } $diff += abs($countsA{$value} - $countsB{$value}) }
|
|---|