I have a program that produces a hash of arrays based on MySQL data. Each array has numerical values in it. Using Perl, how do I generate the entropy of each array and output the results in a seperate MySQL table? The new table should have the columns:
ID Array Entropy
----- ----- -----
1 topic(key) entropy of all values belonging to the topic
Here is the current program that generates the hash of arrays:
my %values_by_topic;
my $sth = $dbh->prepare('SELECT Topic, Value FROM Table');
$sth->execute();
while (my $row = $sth->fetch()) {
my ($topic, $value) = @$row;
push @{ $values_by_topic{$topic} }, $value;
}