[ot-users] Nonsensical output from computeQuantile

Phil Fernandes phil.fernandes at enbridge.com
Tue Sep 5 19:00:34 CEST 2017


Hi Julien,

Thank you for your reply. However, shouldn't the quantiles of continuous unbounded distributions at p=0 and p=1 be undefined and return NaN (or -/+inf if we consider the limits)? What is the purpose of real-numbered boundary values in these cases? If this is a coding convenience, then why does ot.Normal().computeQuantile() not return quantiles that are symmetric about 0 for ot.SpecFunc.MinScalar and 1-ot.SpecFunc.Precision?

Phil


From: users-bounces at openturns.org [mailto:users-bounces at openturns.org] On Behalf Of Julien Schueller | Phimeca
Sent: Monday, September 04, 2017 9:37 AM
To: users at openturns.org
Subject: [External] Re: [ot-users] Nonsensical output from computeQuantile


Maybe we don't want to throw, but I'm not sure.
We never throw, but there are some other cases where the quantile function is not really continuous at the bounds, because in DistributionImplementation::computeQuantile(L2063) we filter according to the values defined in the range attribute:





import openturns as ot
import traceback

factories = ot.DistributionFactory.GetUniVariateFactories()
for factory in factories:
    dist = factory.build()
    try:
        q0 = dist.computeQuantile(0.0)
        qm1 = dist.computeQuantile(-1.0)
        if q0 != qm1:
            print(dist.getName(), '<0', q0, qm1)
        q1 = dist.computeQuantile(1.0)
        q0p = dist.computeQuantile(ot.SpecFunc.MinScalar)
        if q0 != q0p:
            print(dist.getName(), '0+', q0, q0p)
    except:
        print(' exc for', dist.getName())
        traceback.print_exc()
        pass

    try:
        q1 = dist.computeQuantile(1.0)
        q2 = dist.computeQuantile(2.0)
        if q1 != q2:
            print(dist.getName(), '>1', q1, q2)
        q1m = dist.computeQuantile(1.0-ot.SpecFunc.ScalarEpsilon)
        if q1m != q1:
            print(dist.getName(),'1-', q1m, q1)
    except:
        print(' exc for', dist.getName())
        traceback.print_exc()
        pass

________________________________
De : users-bounces at openturns.org<mailto:users-bounces at openturns.org> <users-bounces at openturns.org<mailto:users-bounces at openturns.org>> de la part de Julien Schueller | Phimeca <schueller at phimeca.com<mailto:schueller at phimeca.com>>
Envoyé : lundi 4 septembre 2017 16:40:25
À : users at openturns.org<mailto:users at openturns.org>
Objet : Re: [ot-users] Nonsensical output from computeQuantile


Hello Phil,



- Calling computeQuantile(x) with p outside of (0,1) does not make sense as x is a probability, and it should throw an exception, maybe we should fix that.



- Otherwise the boundary values at x=0 and x=1 seem perfectly fine, (and should not be -/+inf) regarding the continuity of the fonction:

In [32]: ot.Normal().computeQuantile(ot.SpecFunc.MinScalar)
Out[32]: class=Point name=Unnamed dimension=1 values=[-37.5016]

In [42]: ot.Normal().computeQuantile(1-ot.SpecFunc.Precision)
Out[42]: class=Point name=Unnamed dimension=1 values=[8.12589]


j

________________________________
De : users-bounces at openturns.org<mailto:users-bounces at openturns.org> <users-bounces at openturns.org<mailto:users-bounces at openturns.org>> de la part de Phil Fernandes <phil.fernandes at enbridge.com<mailto:phil.fernandes at enbridge.com>>
Envoyé : mercredi 23 août 2017 22:37:37
À : users at openturns.org<mailto:users at openturns.org>
Objet : [ot-users] Nonsensical output from computeQuantile

Hello,

I've noticed that the computeQuantile function, at least for continuous unbounded distributions, yields a nonsensical numerical result with inputs <=0 and >=1. For example, ot.Normal().computeQuantile(x) when x = 0 the output is -37.5194. If I enter x < 0, the output is -7.65063. At the moment I am handling this by subclassing the distribution and overriding the computeQuantile method with an if-else statement that returns -np.inf or np.inf if x = 0 or 1, but this is cumbersome. Would it be possible to incorporate this fix into the source code?

Thank you,
Phil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://openturns.org/pipermail/users/attachments/20170905/9eec636e/attachment.html>


More information about the users mailing list