NAME

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

VERSION

version 0.091310

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 starting value of the accumulator. At present, it is fixed at zero and non-zero starting values have not been tested.

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) 2009 by Ricardo SIGNES.

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