First, let me apologize for my extremely late reply. Right after I
started receiving replies I suffered some pretty serious system
failures. I'm now back and replying to old messages. B
On Mar 2, 2006, at 9:20 AM, Eric Wilhelm wrote:
It sounds like this usage is part of the foundation (if not "base")
class Math::Interval which Brendan will need even though he might not
be working directly on those bits.
Yes, the foundation of the class will have functions that support
traditional interval functions such as overlap() and intersect().
Brendan, do you have some example code? Maybe some code of what
you're
trying to do without the module and corresponding snippets for how you
would like the code to look with the module?
Not at this time. I had finished the basic support that is required
and was about to delve into the implementation of the arithmetic when
I was sidetracked. (See above. ;)
Error bars are a special case of subsets on the real number line in
that
they are rounded to a given precision. So, I would expect
Math::Interval to provide basic arithmetic between intervals as
well as
between numbers and intervals:
my $d = Math::Interval->new(3.2, 4.2);
my $r = $d + 7; # returns an interval [10.2,11.2]
# adding intervals adds the endpoints (ala Math::Vec), right?
my $d = Math::Interval->new(2,4) + Math::Interval->new(3,8);
# returns an interval [5,12]
This is how I envision arithmetic will be implemented. Using
Math::BigInt for inspiration I am implementing the operations as
class functions and then I'll use override to add support for the
various operators.
And then you have intersect(), overlap(), etc for those dealing purely
in interval manipulations, but Brendan wants to generate some error
bars, so he needs Math::ConfidenceInterval, where most of the
calculations return a new Math::Interval object:
my $conf = Math::ConfidenceInterval->new(0.001); # 0.001 accuracy
my $d = $conf->divide(1,3);
# returns a Math::Interval->new(0.333, 0.334);
You don't need to set any accuracy bounds when performing Interval
Arithmetic. The errors that are introduced are a result of IEEE 784
limitations when representing floating point numbers. The way this
example would look is:
# a singleton is an Interval with a zero width.
# the upper and lower bounds are the same.
my $num = Math::Interval->singleton(1); # [1; 1]
my $den = Math::Interval->singleton(3); # [3; 3]
my $result = $num / $den; # implemented as $num->div($den);
# result is approximately [0.3333; 0.3334]
Maybe Brendan isn't planning to flesh-out Math::Interval right now,
but
someone that wants to do that can either send him patches or take over
maintenance of it. I certainly don't think he should be using
something like Math::ConfidenceInterval::Interval when a generic
Interval can be used to represent his results and with a few more
methods could also be applied to the "subsets manipulation" interval
problem.
It's all a matter of time. My plan is to keep fleshing out
Math::Interval as I have time. The first release is going to support
the base functions and the four basic arithmetic operations, +, -, *
and /. If anyone else finds the code useful I would welcome
contributions.
After considering the messages I've received I think the layout
should be:
Math::Interval - The base support required by the other modules.
This module could be used alone to support the traditional concept of
intervals on the number line.
Math::Interval::Arithmetic - Functions for performing arithmetic with
Intervals.
Math::Interval::Functions - Support for trig, logarithmic and other
functions with Intervals.
Math::Interval::Vector - Support for operations on vectors of Intervals.
Math::Interval::Matrix - Support for operations on matrices of
Intervals.
The first two modules would be the initial release and I would
release the other modules when they are ready.
B
--
Brendan Leber
[EMAIL PROTECTED]
If success or failure of this planet and of human beings depended on
how I am and what I do... How would I be? What would I do? -- R.
Buckminster Fuller