GitInsight

 view release on metacpan or  search on metacpan

lib/GitInsight/Util.pm  view on Meta::CPAN

=head1 NAME

GitInsight::Util - A set of functions that uses PDL to produce stats

=head1 SYNOPSIS

    use GitInsight::Util qw(prob label);
    my $prob = prob(100,50); #gives probability using pdf_beta of PDL

=head1 DESCRIPTION

This package contains some functions that uses PDL to do some scientific calculations.

=head1 EXPORTED FUNCTIONS

=head2 prob()

calculate the probability using bayesian inference (C<pdf_beta> of PDL::Stats).
requires two argument, the total number of trials and the watched events that actually matched.

=head2 wday()

Requires a date in string, with this format:

    my $day=wday("2014-03-15")
    #$day is Tue

returns the weekday of the given date

=head2 gen_trans_mat()

Accept an argument, 1 or 0, 1 enable no_day_stats, and it causes to return an empty zero padded piddle.
If the argument is 0 it returns an hashref wich keys are the wdays that contains empty padded zero piddle

=head2 gen_m_mat()

Given a label number as argument, it generates a zero padded matrix of 1 row and of n columns as the label available, with having a 1 only set at the specified label. (used for calculating the prediction)

=head2 markov

requires 3 arguments: the matrix that selects the state (generated by C<gen_m_mat>), the transiction matrix, and the power that must be applied at the transition matrix.
It returns a PDL piddle containing the probability for each next state

=head2 markov_list

requires 3 arguments: the matrix that selects the state (generated by C<gen_m_mat>), the transiction matrix, and the power that must be applied at the transition matrix.
It returns a Perl list containing the probability for each next state.

=head2 markov_prob

requires 3 arguments: the matrix that selects the state (generated by C<gen_m_mat>), the transiction matrix, and the power that must be applied at the transition matrix.
It returns the maximum probability between the future states.

=head2 label

requires 1 argument: the number of commit to be assigned the appropriate label
It returns the assigned label

=head2 label_step

requires an array composed by [0,n] where n is the maximum commit count ever had in a day of the contribution calendar.
it sets the internal data structure to be able to call C<label()>

=head2 info/error/warning

Just used to print the output to the terminal:

    info "All ok"
    error "Something bad happened"
    warning "uh oh!"

=head1 AUTHOR

mudler E<lt>mudler@dark-lab.netE<gt>

=head1 COPYRIGHT

Copyright 2014- mudler

=head1 LICENSE

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

=head1 SEE ALSO

L<GitInsight>, L<PDL>, L<PDL::Stats>

=cut



( run in 1.540 second using v1.01-cache-2.11-cpan-39bf76dae61 )