The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Math::VarRate - deal with linear, variable rates of increase

VERSION

version 0.100000

DESCRIPTION

Math::VarRate is a very, very poor man's calculus. A Math::VarRate object represents an accumulator that increases at a varying rate over time. The rate may change, it is always a linear, positive rate of change.

You can imagine the rate as representing "units gained per time." You can then interrogate the Math::VarRate object for the total units accumulated at any given offset in time, or for the time at which a given number of units will have first been accumulated.

METHODS

new

  my $varrate = Math::VarRate->new(\%arg);

Valid arguments to new are:

  rate_changes   - a hashref in which keys are offsets and values are rates
  starting_value - the value at offset 0 (defaults to 0)

starting_value

This method returns the value of the accumulator at offset 0.

offset_for

  my $offset = $varrate->offset_for($value);

This method returns the offset (positive, from 0) at which the given value is reached. If the given value will never be reached, undef will be returned.

value_at

  my $value = $varrate->value_at($offset);

This returns the value in the accumulator at the given offset.

AUTHOR

Ricardo SIGNES <rjbs@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by Ricardo SIGNES.

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