# NumPy Statistical Functions - NumPy

## What are the statistical functions provided by NumPy?

The statistical functions provided by NumPy facilitate in finding the minimum, maximum and percentile standard deviation, variance etc. The different functions for performing these operations are:

### numpy.amin() and numpy.amax()

The minimum and the maximum out of the elements of the given array along the specified axis is returned by this function.

Example

The output appears as:

### numpy.ptp()

The range from maximum to minimum of the axis values is returned by this function.

Example

The output appears as:

### numpy.percentile()

The percentile of the given elements is returned by this function. The parameters of the function are:

Where,

 S.No Argument & Description 1. a Input array 2. q The percentile to compute must be between 0-100 3. axis The axis along which the percentile is to be calculated

Example

The output appears as:

### numpy.median()

Median separates the higher half of the sample data from the lower half.

Example

The output appears as:

### numpy.mean()

The sum of elements along the axis divided by the number of elements is defined as the arithmetic mean. The arithmetic mean of the elements of the array is returned by this function, along a specified axis.

Example

The output appears as:

### numpy.average()

The weighted average of the elements in the array in correspondence to the weight in another array is computed by this function. The average that is the result from multiplying the component by a factor is the weighted average. The function has the axis parameter and if there is no specified axis, the array is flattened.

For instance, consider an array [1,2,3,4] and corresponding weights [4,3,2,1], the weighted average is calculated by adding the product of the corresponding elements and dividing the sum by the sum of weights.

Weighted average = (1*4+2*3+3*2+4*1)/(4+3+2+1)

Example

The output appears as:

The axis is definitely defined for a multi-dimensional array.

Example

The output appears as:

### Standard Deviation

The square root of the average of the squared deviations from the mean is known as Standard deviation. The standard deviation is calculated by the formula:

For instance, if the array is [1, 2, 3, 4], then its mean is 2.5. Hence the squared deviations are [2.25, 0.25, 0.25, 2.25] and the square root of its mean divided by 4, i.e., sqrt (5/4) is 1.1180339887498949.

Example

The output appears as:

### Variance

The average of the squared deviations is the variance. Standard deviation is the square root of variance.

Example

The output appears as:

NumPy Topics