[SciPy-dev] scipy.stats: sf for symmetric distributions.
Wed Sep 16 14:17:48 CDT 2009
On Wed, Sep 16, 2009 at 3:06 PM, <firstname.lastname@example.org> wrote:
> On Wed, Sep 16, 2009 at 2:50 PM, David Warde-Farley <email@example.com> wrote:
>> I just noticed that the way _sf() is implemented in the base class is
>> particularly horrible for continuous distributions that are symmetric
>> about the origin, where 1.0 - cdf(x) is prone to roundoff error and
>> could just as easily be calculated as cdf(-x).
>> I wonder if this is a common enough case that that there ought to be
>> an rv_continuous_zerosym class that candidate distributions inherit
>> from, or if we should just override the method on a case by case basis.
> Without checking the different cases, I would say, add them to the individual
> distributions, def _sf(self) ... return self._cdf(-x)
> I'm not sure there are enough cases to separate them out for
> numerical improvements, if it only needs the addition of one or two lines
> for the relevant cases.
> There are also other cases, where the generic procedure could be chosen
> in a smarter way to make the calculations faster or more accurate.
> Besides some improvements by Per, not much has been done to improve
> numerical precision.
Did you check for which distributions this would apply?
I remember there was some problem that pymvpa had with the r
distribution because the numerical integration close to the lower
bound didn't work.
I thought for some time whether I should use to upper tail instead,
which would be the reverse of what you are proposing, but I didn't
manage to figure out which would be more accurate. I was also thinking
whether numerical integration should start at the center for symmetric
distributions. But I know too little about the precision of numerical
integration to fight for 1e-XX.
>> Scipy-dev mailing list
More information about the Scipy-dev