Boost logo

Boost :

Subject: Re: [boost] [math distributions] where to check for validity of distribution variables?
From: Thijs van den Berg (thijs_at_[hidden])
Date: 2008-11-26 15:09:56


John Maddock wrote:
> Thijs van den Berg wrote:
>>> ah! you're saying you van have one type of policy for the
>>> distribution (construtor) and another policy
>>> type in some non-member function like pdf.
>>> that explains the things I'm seeing!
>
> Nope, the policy that the distribution has applies to all the
> non-member functions as well, it's just that the *error handlers may
> not throw, but return an error value instead*.
>
>>> A final question regarding the error checking is this:
>>> Suppose a distribution has a couple of valid an invalid parameters.
>>> E.g. normal(2,0), whith has a valid
>>> mean=2 and invalid std=0. Formally that would make the distribution
>>> object invalid... There are at least
>>> two possible view on what to do with non-member fuctions.
>>> 1) Make *all* of them return NaN because the distribution in invalid.
>>> This is a mathematical interpretation
>>> or
>>> 2) (current implementation) try to give an answer when possible,
>>> this is
>>> a "can we calculate the result?"
>>> interpretation. In this case we can calculate the mean (it's 2), but
>>> we
>>> can't calculate the pdf because
>>> that would give an divide by zero.
>>>
>>> I'm asking this because I'd like to stick to you're approach with new
>>> code, and *not* because I want
>>> to discuss a preference for any of the two... :)
>
> Ah, OK, in that case, let's continue with the status quo :-)
>
> John.
>
very good! Non-member functions will
*only check the distribution parameters they need for their calculation
(and no other parameters)
* will return a sensible value if all those parameters are ok
* not throw an error if other parameters have rendered the distribution
mathematically invalid.

in that case, I don't see an really big use for an is_valid() or
check_parameters() member function (for now)

-- 
SITMO Quantitative Financial Consultancy - Software Development
M.A. (Thijs) van den Berg
Tel.+31 (0)6 2411 0061
Fax.+31 (0)15 285 1984
thijs_at_[hidden] <mailto:thijs_at_[hidden]> - www.sitmo.com 
<http://www.sitmo.com>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk