← All procedures

statistics.signFlipTest

The sign-flip test of a sum of terms. Under the null, each term has the sign + or - with equal chance. The statistic is the absolute value of the sum. A weighted mean of paired differences is such a sum: give the terms `w[i] * d[i]`.

CLI
Package
@procedures/statistics · README
Path
["statistics","signFlipTest"]
CLI
mark statistics signFlipTest --terms <number[]>
As data
{"$proc":["statistics","signFlipTest"],"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","signFlipTest"], { terms: [] });
console.log(JSON.stringify(result));

From the command line

$ mark statistics signFlipTest --terms <number[]>

As data, in a program

{ "$proc": ["statistics", "signFlipTest"], "input": { "terms": [] } }

Input

FieldTypeRequiredDefaultDescription
termsnumber[]yes
optionsobjectno

Output

FieldTypeRequiredDefaultDescription
observednumberyesThe absolute value of the sum of the terms.
pnumberyesThe two-sided p.
exactbooleanyesThis field is true when the test read each sign set, so the p has no noise from the draws.
runsnumberyesThe count of the sign sets that the test read: `2^n` when it is exact, otherwise the count of the draws.
JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "terms": {
        "type": "array",
        "items": {
          "type": "number"
        }
      },
      "options": {
        "type": "object",
        "properties": {
          "exactMax": {
            "type": "number",
            "description": "The largest count of terms for which the test reads each of the `2^n` sign sets. The default is 16. The most is 24."
          },
          "runs": {
            "type": "number",
            "description": "The count of random sign sets above `exactMax`. The default is 10 000."
          },
          "seed": {
            "description": "The default is 1.",
            "type": [
              "string",
              "number"
            ]
          }
        },
        "additionalProperties": {}
      }
    },
    "required": [
      "terms"
    ],
    "additionalProperties": false
  },
  "output": {
    "type": "object",
    "properties": {
      "observed": {
        "type": "number",
        "description": "The absolute value of the sum of the terms."
      },
      "p": {
        "type": "number",
        "description": "The two-sided p."
      },
      "exact": {
        "type": "boolean",
        "description": "This field is true when the test read each sign set, so the p has no noise from the draws."
      },
      "runs": {
        "type": "number",
        "description": "The count of the sign sets that the test read: `2^n` when it is exact, otherwise the count of the draws."
      }
    },
    "required": [
      "observed",
      "p",
      "exact",
      "runs"
    ],
    "additionalProperties": {}
  }
}