File: t_Distribution_quantile.py

package info (click to toggle)
openturns 1.24-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 66,204 kB
  • sloc: cpp: 256,662; python: 63,381; ansic: 4,414; javascript: 406; sh: 180; xml: 164; yacc: 123; makefile: 98; lex: 55
file content (32 lines) | stat: -rwxr-xr-x 958 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#! /usr/bin/env python

import openturns as ot

ot.TESTPREAMBLE()

factories = ot.DistributionFactory.GetUniVariateFactories()
for factory in factories:
    dist = factory.build()
    try:
        qm1 = dist.computeQuantile(-1.0)
        raise ValueError(
            f"Expected a TypeError but with dist = {dist} got quantile(-1) = {qm1}"
        )
    except TypeError:
        pass
    try:
        q2 = dist.computeQuantile(2.0)
        raise ValueError(
            f"Expected a TypeError but with dist = {dist} got quantile(2) = {q2}"
        )
    except TypeError:
        pass
    q0 = dist.computeQuantile(0.0)[0]
    q1 = dist.computeQuantile(1.0)[0]
    q0p = dist.computeQuantile(ot.SpecFunc.MinScalar)[0]
    if not q0 <= q0p:
        print(dist.getName(), "0+", q0, q0p)
    q1 = dist.computeQuantile(1.0)[0]
    q1m = dist.computeQuantile(1.0 - ot.SpecFunc.ScalarEpsilon)[0]
    if not q1m <= q1:
        print(dist.getName(), "1-", q1m, q1)