{ } Raw JSON

bundles / scipy 1.17.1 / scipy / stats / _mstats_basic / variation

function

scipy.stats._mstats_basic:variation

source: /scipy/stats/_mstats_basic.py :2765

Signature

def   variation ( a axis = 0 ddof = 0 )

Summary

Compute the coefficient of variation.

Extended Summary

The coefficient of variation is the standard deviation divided by the mean. This function is equivalent to

np.std(x, axis=axis, ddof=ddof) / np.mean(x)

The default for ddof is 0, but many definitions of the coefficient of variation use the square root of the unbiased sample variance for the sample standard deviation, which corresponds to ddof=1.

Parameters

a : array_like

Input array.

axis : int or None, optional

Axis along which to calculate the coefficient of variation. Default is 0. If None, compute over the whole array a.

ddof : int, optional

Delta degrees of freedom. Default is 0.

Returns

variation : ndarray

The calculated variation along the requested axis.

Notes

For more details about variation, see scipy.stats.variation.

Examples

import numpy as np
from scipy.stats.mstats import variation
a = np.array([2,8,4])
variation(a)
b = np.array([2,8,3,4])
c = np.ma.masked_array(b, mask=[0,0,1,0])
variation(c)
In the example above, it can be seen that this works the same as `scipy.stats.variation` except 'stats.mstats.variation' ignores masked array elements.

Aliases

  • scipy.stats._mstats_basic.variation

Referenced by

This package