Lingua::Diversity::Result - storing the result of a diversity measurement
This documentation refers to Lingua::Diversity::Result version 0.04.
use Lingua::Diversity::Result; # Given a Lingua::Diversity derived object and an array of data... # Measure diversity in the data and store the result in a Result object. my $result = $diversity->measure( \@data ); # A Result object always has a main 'diversity' field... print "Diversity\t", $result->get_diversity(), "\n"; # ... and may have a 'variance' and 'count' field... if ( $result->has_variance() ) { print "Variance\t", $result->get_variance(), "\n"; } if ( $result->has_count() ) { print "Count\t", $result->get_count(), "\n"; }
This class implements the result of a Lingua::Diversity derived object's diversity measurement. All diversity measures return a main value stored in the Result's diversity attribute. Those measures for which the main value is an average may also return the corresponding variance and count (i.e. number of observations), which are then stored in the Result's variance and count attributes (this should be documented in the Lingua::Diversity derived class).
The creator (new()) returns a new Lingua::Diversity::Result object. In principle, the end user should never call it directly since it is invoked by the measure() and measure_per_category() methods of a given Lingua::Diversity derived class.
new()
measure()
measure_per_category()
The constructor takes one required and two optional named parameters:
A number characterizing the diversity measured in the data.
If the value of the diversity attribute is an average, this attribute stores the corresponding variance.
If the value of the diversity attribute is an average, this attribute stores the corresponding number of observations. In the case of a weighted average, the value of this attribute is the sum of weights, which needs not be an integer.
Getter for the diversity attribute.
Getter and predicate for the variance attribute.
Getter and predicate for the count attribute.
This module is part of the Lingua::Diversity distribution, and extends Lingua::Diversity.
There are no known bugs in this module.
It has been designed under the assumption that a unified set of fields would be convenient to characterize the output of various diversity measures. It turns out that this assumption makes it necessary to leave a lot of useful information out of the results, because the output of every diversity measure has some specificity (besides commonalities with other measures). In a future version, this could be solved by making the Lingua::Diversity::Class (at least partly) abstract, and by designing a derived class for each diversity measure.
Please report problems to Aris Xanthos (aris.xanthos@unil.ch)
Patches are welcome.
Aris Xanthos (aris.xanthos@unil.ch)
Copyright (c) 2011 Aris Xanthos (aris.xanthos@unil.ch).
This program is released under the GPL license (see http://www.gnu.org/licenses/gpl.html).
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Lingua::Diversity
To install Lingua::Diversity, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Lingua::Diversity
CPAN shell
perl -MCPAN -e shell install Lingua::Diversity
For more information on module installation, please visit the detailed CPAN module installation guide.