Statistics

Statistics

Represents statistical measurements for a numeric sequence. Provides access to summary statistics (count, min, max, average, range, sum, variance, standard deviation) and, optionally, extended calculations (mode, median) if computed during construction. Use `clone()` to create a duplicate of an instance, and `toJSON()` to serialize it.

Constructor

new Statistics(count, minimum, maximum, range, average, summary, mode, median, variance, standardDeviation)

Description:
  • Initializes a new instance of Statistics.
Source:
Parameters:
Name Type Description
count number The number of items in the sequence.
minimum number | undefined The minimal value in the sequence, or undefined if not applicable.
maximum number | undefined The maximal value in the sequence, or undefined if not applicable.
range number | undefined The range of the sequence (maximum - minimum), or undefined if not applicable.
average number | undefined The average value of the sequence, or undefined if not applicable.
summary number The sum of all values in the sequence.
mode Array.<number> | undefined The most frequent values, or undefined if not calculated.
median number | undefined The middle value when sorted, or undefined if not calculated.
variance number | undefined The variance of the sequence, or undefined if not calculated.
standardDeviation number | undefined The standard deviation (square root of variance), or undefined if not calculated.

Members

average

Description:
  • The average value of the sequence, or undefined if not applicable.
Source:
The average value of the sequence, or undefined if not applicable.

count

Description:
  • The number of items in the sequence.
Source:
The number of items in the sequence.

maximum

Description:
  • The maximal value in the sequence, or undefined if not applicable.
Source:
The maximal value in the sequence, or undefined if not applicable.

median

Description:
  • The middle value when sorted, or undefined if not calculated.
Source:
The middle value when sorted, or undefined if not calculated.

minimum

Description:
  • The minimal value in the sequence, or undefined if not applicable.
Source:
The minimal value in the sequence, or undefined if not applicable.

mode

Description:
  • The most frequent values, or undefined if not calculated.
Source:
The most frequent values, or undefined if not calculated.

range

Description:
  • The range of the sequence (maximum - minimum), or undefined if not applicable.
Source:
The range of the sequence (maximum - minimum), or undefined if not applicable.

standardDeviation

Description:
  • The standard deviation (square root of variance), or undefined if not calculated.
Source:
The standard deviation (square root of variance), or undefined if not calculated.

summary

Description:
  • The sum of all values in the sequence.
Source:
The sum of all values in the sequence.

variance

Description:
  • The variance of the sequence, or undefined if not calculated.
Source:
The variance of the sequence, or undefined if not calculated.

Methods

clone() → {Statistics}

Description:
  • Creates a deep copy of the current `Statistics` instance.
Source:
Returns:
A cloned `Statistics` instance with the same values.
Type
Statistics

equal(value, precision)

Description:
  • Returns `true` if the current object equal to the specified value.
Source:
Parameters:
Name Type Description
value Statistics `true` if the current object equal to the specified.
precision number The number of digits after the decimal point to compare.

toJSON() → {Object}

Description:
  • Returns a plain JSON object representing the current `Statistics` instance.
Source:
Returns:
A JSON-serializable object containing all statistical properties.
Type
Object

(static) empty() → {Statistics}

Description:
  • Creates a Statistics instance representing an empty sequence.
Source:
Returns:
An instance with zero or undefined values and no extended calculations.
Type
Statistics

(static) fromJSON(json) → {Statistics}

Description:
  • Creates a `Statistics` instance from a plain JSON object.
Source:
Parameters:
Name Type Description
json Object A plain object with the same properties as produced by `toJSON()`.
Throws:
If the input is not an object or missing required fields.
Type
Error
Returns:
A new `Statistics` instance populated from the given JSON object.
Type
Statistics