NAME
Math::VarRate - deal with linear, variable rates of increase
VERSION
version 0.100001
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.
PERL VERSION
This library should run on perls released even a long time ago. It should work on any version of perl released in the last five years.
Although it may work on older versions of perl, no guarantee is made that the minimum required version will not be increased. The version may be increased for any reason, and there is no promise that patches will be accepted to lower the minimum required perl.
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 <cpan@semiotic.systems>
CONTRIBUTOR
Ricardo Signes <rjbs@semiotic.systems>
COPYRIGHT AND LICENSE
This software is copyright (c) 2022 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.