NAME

Algorithm::Statistic - different statistical algorithms library

VERSION

Version 0.04

SYNOPSIS

use Algorithm::Statistic qw/:all/;

DESCRIPTION

This module provides several math and statistical algorithms implementations in C++ XS for perl.

Functions

kth_order_statistic(array_ref, k [, \&compare])

This function allows to find k-th order statistic for certain array of elements. Note that this function changes input array (like std::nth_element im STL C++) according to the next rule: element at k-th position will become k-th order atatistic. Each element from the left of k will be less then k-th and each from the right will be greater. This algorithm works with linear complexity O(n). By default you don't have to specify comparator for integers and float numbers.

my $statistic = kth_order_statistic($array_ref, $k);

But in more complex cases it's posible to specify comparator.

my $statistic_cmp = kth_order_statistic($array_ref, $k, \&compare);

For example compare function could be simple comparison for strings:

sub compare {
    $_[0] cmp $_[1]
}

median(array_ref, \&compare)

This function allows to find median for certain array of elements. This method is the same as n/2 kth order statistc. Like kth_order_statistic this function changes input array according to the same rule.

my $median = median($array_ref [, \&compare]);

BUGS

If you find a bug please contact me via email.

AUTHOR

Igor Karbachinsky <igorkarbachinsky@mail.ru>

LICENSE AND COPYRIGHT

Copyright (c) 2015, Igor Karbachinsky. All rights reserved.