Calculate

Calculate

  • Docs
  • Help
  • Blog

›Statistics

Getting Started

  • Installation
  • Updating Calculate

Math

  • Sum
  • Difference
  • Product
  • Quotient
  • Remainder
  • Power
  • Square
  • Cube
  • Factorial

Statistics

  • Mean
  • Median
  • Mode
  • Range

Mean

Gets the mean of given numbers by getting its sum then divide to its length.

Syntax

mean(a: number, b: number, ...args): number

Parameters

a: number - First given number.

b: number - Second given number.

...args: number[] - The rest of the given numbers

Can be given an infinite number of parameters.

Returns

number - The resulting mean.

Error

Throws an error if the length of arguments is less than 2.

Import

import { mean } from '@princedev/calculate';

Examples

Basic usage with two given numbers.

const result = mean(12,4);

result would be 8

Getting the average of multiple given nnumbers.

const result = mean(2, 4, 6);

result would be 4

If you're using an array, you can use the spread operator like this

const result = mean(...[2, 4, 6]);

result would be 4

Last updated on 5/6/2020 by Prince Neil Cedrick Castro
← FactorialMedian →
  • Syntax
    • Parameters
    • Returns
    • Error
  • Import
  • Examples
Calculate
Docs
Getting StartedGuides
Package
NPMGitHubStar
More
HelpBlog
aws.cedi@gmail.com
Copyright © 2020 Calculate