Jarkko Hietaniemi > Statistics-Simpson > Statistics::Simpson

Download:
Statistics-Simpson-0.01.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  0
View/Report Bugs
Module Version: 0.01   Source  

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 ^

The 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.

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

Statistics::Shannon

For the data manipulation interface see (though the whole interface is documented here)

Statictics::Frequency

AUTHOR, COPYRIGHT, LICENSE ^

Jarkko Hietaniemi <jhi@iki.fi> Copyright 2002

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: