Math::VarRate - deal with linear, variable rates of increase
version 0.100001
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.
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.
my $varrate = Math::VarRate->new(\%arg);
Valid arguments to new are:
new
rate_changes - a hashref in which keys are offsets and values are rates starting_value - the value at offset 0 (defaults to 0)
This method returns the value of the accumulator at offset 0.
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.
my $value = $varrate->value_at($offset);
This returns the value in the accumulator at the given offset.
Ricardo SIGNES <cpan@semiotic.systems>
Ricardo Signes <rjbs@semiotic.systems>
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.
To install Math::VarRate, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Math::VarRate
CPAN shell
perl -MCPAN -e shell install Math::VarRate
For more information on module installation, please visit the detailed CPAN module installation guide.