statistics.binomialTest
This function gives the p of the exact one-sided binomial test of `k` successes in `n` trials, with X ~ Binomial(n, p). The side `"less"` gives `P(X <= k)`. A small value rejects the claim "the chance is `p` or more". The side `"greater"` gives `P(X >= k)`. A small value rejects the claim "the chance is `p` or less".
CLI- Package
- @procedures/statistics · README
- Path
["statistics","binomialTest"]- CLI
mark statistics binomialTest --k <number> --n <number> --p <number> --side <"greater" | "less">- As data
{"$proc":["statistics","binomialTest"],"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","binomialTest"], { k: 1, n: 1, p: 1, side: "greater" });
console.log(JSON.stringify(result));From the command line
$ mark statistics binomialTest --k <number> --n <number> --p <number> --side <"greater" | "less">
As data, in a program
{
"$proc": ["statistics", "binomialTest"],
"input": { "k": 1, "n": 1, "p": 1, "side": "greater" }
}Input
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
k | number | yes | The count of successes, a whole number from 0 to `n`. | |
n | number | yes | The count of trials, a whole number of 0 or more. | |
p | number | yes | The chance of a success under the claim, from 0 to 1. | |
side | "greater" | "less" | yes | The side of the tail. |
Output
The schema does not list fields (number).
JSON Schemas
{
"input": {
"type": "object",
"properties": {
"k": {
"type": "number",
"description": "The count of successes, a whole number from 0 to `n`."
},
"n": {
"type": "number",
"description": "The count of trials, a whole number of 0 or more."
},
"p": {
"type": "number",
"description": "The chance of a success under the claim, from 0 to 1."
},
"side": {
"type": "string",
"enum": [
"greater",
"less"
],
"description": "The side of the tail."
}
},
"required": [
"k",
"n",
"p",
"side"
],
"additionalProperties": false
},
"output": {
"type": "number"
}
}