NAME
Statistics::Simpson - Simpson index
SYNOPSIS
The object-oriented interface:
use Statistics::Simpson;
# The constructor is inherited from Statistics::Frequency.
my $pop = Statistics::Simpson->new(@data);
my $pop = Statistics::Simpson->new(\@data);
my $pop = Statistics::Simpson->new(\%data);
my $pop = Statistics::Simpson->new($another);
# The Simpson index and the Simpson evenness.
print $pop->index, "\n";
print $pop->evenness, "\n";
The "anonymous" interface where the population data is not a Statistics::Frequency object but instead either an array reference, in which case the array elements are the frequencies, or a hash reference, in which keys the hash values are the frequencies.
use Statistics::Simpson;
print Statistics::Simpson::index([ data ]), "\n";
print Statistics::Simpson::index({ data }), "\n";
print Statistics::Simpson::evenness([ data ]), "\n";
print Statistics::Simpson::evenness({ data }), "\n";
The rest of data manipulation interface inherited from Statistics::Frequency:
$pop->add_data(@more_data);
$pop->add_data(\@more_data);
$pop->add_data(\%more_data);
$pop->add_data($another);
$pop->remove_data(@less_data);
$pop->remove_data(\@less_data);
$pop->remove_data(\%less_data);
$pop->remove_data($another);
$pop->copy_data($another);
$pop->clear_data();
DESCRIPTION
Statistics::Simpson module can be used to compute the Simpson index of data, which measures the variability of data.
The index() and evenness() interfaces are the only genuine interfaces of this module, the constructor and the rest of the data manipulation interface is inherited from Statistics::Frequency.
new
my $pop = Statistics::Simpson->new(@data);
my $pop = Statistics::Simpson->new(\@data);
my $pop = Statistics::Simpson->new(\%data);
my $pop = Statistics::Simpson->new($another);
Creates a new Simpson object from the initial data.
The data may be either a list, a reference to an array or a reference to a hash.
If the data is a list (or an array), the list elements are counted to find out their frequencies.
If the data is a reference to an array, the array elements are counted to find out their frequencies.
If the data is a reference to a hash, the hash keys are the data elements and the hash values are the data frequencies.
If the data is another Statistics::Simpson object, its frequencies are used.
index
$pop->index;
Return the Simpson index of the data. The index is defined as
$Simpson = 1 / sum($p{$e}**2)
where the $p{$e} is the proportional [0,1] frequency of the element $e. The value of the index ranges from 1 (the population is dominated by one kind) to the number of different elements (the population is evenly divided).
The Simpson index is used in biology and ecology, especially when talking about populations and biodiversity.
evenness
Evenness measures how similar the frequencies are.
$Evenness = $Simpson / $NumberOfDifferentElements
When all the frequencies are equal, evenness is one. Frequency imbalance lowers the evenness value.
add_data
$pop->add_data(@more_data);
$pop->add_data(\@more_data);
$pop->add_data(\%more_data);
$pop->add_data($another);
Add more data to the object. The arguments are as in new().
remove_data
$pop->remove_data(@less_data);
$pop->remove_data(\@less_data);
$pop->remove_data(\%less_data);
$pop->remove_data($another);
Remove data from the object. The arguments are as in new(). The frequencies of data elements are gapped at zero.
copy_data
$pop->clear_data($another);
Copy all data from another object. The old data is discarded.
clear_data
$pop->clear_data();
Remove all data from the object.
SEE ALSO
For another variability index see
For the data manipulation interface see (though the whole interface is documented here)
COPYRIGHT AND LICENSE
Copyright (C) 2002-2015, Jarkko Hietaniemi <jhi@iki.fi>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl 5.18.2.