Macaulay2 » Documentation
Packages » Probability » ProbabilityDistribution » QuantileFunction » quantile
next | previous | forward | backward | up | index | toc

# quantile -- quantile function

- Usage:
    `quantile_X p`
- Inputs:
  - X, a probability distribution,
  - p, a real number,
- Optional inputs:
  - LowerTail => a Boolean value, default value true
- Outputs:
  - a real number,

## Description

For continuous probability distributions, the quantile function is the inverse of the cumulative distribution function, i.e., \(x\) for which \(P(X \leq x) = p\).

    i1 : Z = normalDistribution()

    o1 = N(0,1)

    o1 : ContinuousProbabilityDistribution

    i2 : quantile_Z 0.95

    o2 = 1.644853626951472

    o2 : RR (of precision 53)

    i3 : probability_Z oo

    o3 = .95

    o3 : RR (of precision 53)

For discrete probability distributions, it returns the smallest \(x\) for which \(P(X \leq x) \geq p\).

    i4 : X = binomialDistribution(10, 0.25)

    o4 = B(10,.25)

    o4 : DiscreteProbabilityDistribution

    i5 : quantile_X 0.75

    o5 = 3

    i6 : probability_X 2

    o6 = .5255928039550778

    o6 : RR (of precision 53)

    i7 : probability_X 3

    o7 = .7758750915527344

    o7 : RR (of precision 53)

If the LowerTail option is false, then it instead finds \(x\) for which \(P(X > x) = p\) in the continuous case.

    i8 : quantile_Z(0.95, LowerTail => false)

    o8 = -1.644853626951472

    o8 : RR (of precision 53)

    i9 : probability_Z(oo, LowerTail => false)

    o9 = .95

    o9 : RR (of precision 53)

In the discrete case, it finds the smallest \(x\) for which \(P(X > x) \leq p\).

    i10 : quantile_X(0.75, LowerTail => false)

    o10 = 2

    i11 : probability_X(2, LowerTail => false)

    o11 = .4744071960449222

    o11 : RR (of precision 53)

    i12 : probability_X(1, LowerTail => false)

    o12 = .7559747695922852

    o12 : RR (of precision 53)

## Ways to use quantile:

- `quantile(DiscreteProbabilityDistribution,Number)`
- `quantile(ProbabilityDistribution,Number)`

## For the programmer

The object quantile is a method function with options.

The source of this document is in /build/macaulay2-88fgJW/macaulay2-1.25.11+ds/M2/Macaulay2/packages/Probability.m2:737:0.