[SciPy-dev] scipy.stats: sf for symmetric distributions.

josef.pktd@gmai... josef.pktd@gmai...
Wed Sep 16 14:06:51 CDT 2009

On Wed, Sep 16, 2009 at 2:50 PM, David Warde-Farley <dwf@cs.toronto.edu> wrote:
> Hi,
> 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.
> David

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.


> _______________________________________________
> Scipy-dev mailing list
> Scipy-dev@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-dev

More information about the Scipy-dev mailing list