← All procedures

statistics.runningMean

This function gives the mean of the values: `sum / n`. It throws a RangeError for the empty summary.

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

From the command line

$ mark statistics runningMean --s <object>

As data, in a program

{ "$proc": ["statistics", "runningMean"], "input": { "s": {} } }

Input

FieldTypeRequiredDefaultDescription
sobjectyes

Output

The schema does not list fields (number).

JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "s": {
        "type": "object",
        "properties": {
          "n": {
            "type": "number",
            "description": "The count of the values."
          },
          "sum": {
            "type": "number",
            "description": "The sum of the values, added in their order."
          },
          "min": {
            "type": "number",
            "description": "The smallest value, or `Infinity` for no value."
          },
          "max": {
            "type": "number",
            "description": "The largest value, or `-Infinity` for no value."
          },
          "m2": {
            "type": "number",
            "description": "The sum of the squares of the differences from the mean (Welford). `runningSd` reads it."
          }
        },
        "required": [
          "n",
          "sum",
          "min",
          "max",
          "m2"
        ],
        "additionalProperties": {}
      }
    },
    "required": [
      "s"
    ],
    "additionalProperties": false
  },
  "output": {
    "type": "number"
  }
}