← All procedures

statistics.quantileInterval

This function gives the distribution-free interval of the quantile `p` of a sample. Each tail outside the interval holds (1 - level) / 2 or less. Let X ~ Binomial(n, p). The lower rank is the largest l with P(X <= l - 1) in the tail. The upper rank is the smallest u with P(X >= u) in the tail. The values must be independent draws, or the coverage is false.

CLI
Package
@procedures/statistics · README
Path
["statistics","quantileInterval"]
CLI
mark statistics quantileInterval --values <number[]> --p <number>
As data
{"$proc":["statistics","quantileInterval"],"input":{}}

Use it

In TypeScript

import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/statistics/register"; // registers its procedures

const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["statistics","quantileInterval"], { values: [], p: 1 });
console.log(JSON.stringify(result));

From the command line

$ mark statistics quantileInterval --values <number[]> --p <number>

As data, in a program

{
  "$proc": ["statistics", "quantileInterval"],
  "input": { "values": [], "p": 1 }
}

Input

FieldTypeRequiredDefaultDescription
valuesnumber[]yes
pnumberyes
levelnumberno

Output

FieldTypeRequiredDefaultDescription
lownumberyesThe value x_(lowRank), or `-Infinity` when the sample has no rank for a lower bound.
highnumberyesThe value x_(highRank), or `Infinity` when the sample has no rank for an upper bound.
lowRanknumberyesThe rank of `low`, from 1, or 0 when `low` is `-Infinity`.
highRanknumberyesThe rank of `high`, from 1, or n + 1 when `high` is `Infinity`.
coveragenumberyesThe chance that the interval holds the quantile of the population.
JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "values": {
        "type": "array",
        "items": {
          "type": "number"
        }
      },
      "p": {
        "type": "number"
      },
      "level": {
        "type": "number"
      }
    },
    "required": [
      "values",
      "p"
    ],
    "additionalProperties": false
  },
  "output": {
    "type": "object",
    "properties": {
      "low": {
        "type": "number",
        "description": "The value x_(lowRank), or `-Infinity` when the sample has no rank for a lower bound."
      },
      "high": {
        "type": "number",
        "description": "The value x_(highRank), or `Infinity` when the sample has no rank for an upper bound."
      },
      "lowRank": {
        "type": "number",
        "description": "The rank of `low`, from 1, or 0 when `low` is `-Infinity`."
      },
      "highRank": {
        "type": "number",
        "description": "The rank of `high`, from 1, or n + 1 when `high` is `Infinity`."
      },
      "coverage": {
        "type": "number",
        "description": "The chance that the interval holds the quantile of the population."
      }
    },
    "required": [
      "low",
      "high",
      "lowRank",
      "highRank",
      "coverage"
    ],
    "additionalProperties": {}
  }
}