sciPy stats.variation() function | Python Last Updated : 13 Feb, 2019 Comments Improve Suggest changes Like Article Like Report scipy.stats.variation(arr, axis = None) function computes the coefficient of variation. It is defined as the ratio of standard deviation to mean. Parameters : arr : [array_like] input array. axis : [int or tuples of int] axis along which we want to calculate the coefficient of variation. -> axis = 0 coefficient of variation along the column. -> axis = 1 coefficient of variation working along the row. Results : Coefficient of variation of the array with values along specified axis. Code #1: Use of variation() Python3 1== from scipy.stats import variation import numpy as np arr = np.random.randn(5, 5) print ("array : \n", arr) # rows: axis = 0, cols: axis = 1 print ("\nVariation at axis = 0: \n", variation(arr, axis = 0)) print ("\nVariation at axis = 1: \n", variation(arr, axis = 1)) Output: array : [[-1.16536706 -1.29744691 -0.39964651 2.14909277 -1.00669835] [ 0.79979681 0.91566149 -0.823054 0.9189682 -0.01061181] [ 0.9532622 0.38630077 -0.79026789 -0.70154086 0.79087801] [ 0.53553389 1.46409899 1.89903817 -0.35360202 -0.14597738] [-1.53582875 -0.50077039 -0.23073327 0.32457064 -0.43269088]] Variation at axis = 0: [-12.73042404 5.10272979 -14.6476392 2.15882202 -3.64031032] Variation at axis = 1: [-3.73200773 1.90419038 5.77300406 1.29451485 -1.27228112] Code #2: How to implement without variation() Python3 1== import numpy as np arr = np.random.randn(5, 5) print ("array : \n", arr) # this function works similar to variation() cv = lambda x: np.std(x) / np.mean(x) var1 = np.apply_along_axis(cv, axis = 0, arr = arr) print ("\nVariation at axis = 0: \n", var1) var2 = np.apply_along_axis(cv, axis = 1, arr = arr) print ("\nVariation at axis = 0: \n", var2) Output: array : [[ 0.51268414 -1.93697931 0.41573223 2.14911168 0.15036631] [-0.50407207 1.51519879 -0.42217231 -1.09609322 1.93184432] [-1.07727163 0.27195529 -0.1308108 -1.75406388 0.94046395] [ 1.23283059 -0.03112461 0.59725109 0.06671002 -0.97537666] [ 1.1233506 0.97658799 -1.10309113 -1.33142901 -0.28470146]] Variation at axis = 0: [ 3.52845174 7.40891024 -4.74078192 -3.57928544 2.85092056] Variation at axis = 0: [ 5.04874565 4.22763514 -2.74104828 4.10772935 -8.24126977] Comment More infoAdvertise with us Next Article sciPy stats.variation() function | Python V vishal3096 Follow Improve Article Tags : Python Python-scipy Python scipy-stats-functions Practice Tags : python Similar Reads sciPy stats.tvar() function | Python scipy.stats.tvar(array, limits=None, inclusive=(1, 1)) function calculates the trimmed variance of the array elements along with ignoring the values lying outside the specified limits. It's formula - Parameters : array: Input array or object having the elements to calculate the trimmed variance. lim 2 min read sympy.stats.variance() function in Python In mathematics, the variance is the way to check the difference between the actual value and any random input, i.e variance can be calculated as a squared difference of these two values. With the help of sympy.stats.variance() method, we can calculate the value of variance by using this method. Synt 1 min read scipy stats.kurtosis() function | Python scipy.stats.kurtosis(array, axis=0, fisher=True, bias=True) function calculates the kurtosis (Fisher or Pearson) of a data set. It is the fourth central moment divided by the square of the variance. It is a measure of the "tailedness" i.e. descriptor of shape of probability distribution of a real-va 2 min read sciPy stats.signaltonoise() function | Python scipy.stats.signaltonoise(arr, axis=0, ddof=0) function computes the signal-to-noise ratio of the input data. Its formula : Parameters :arr : [array_like]Input array or object having the elements to calculate the signal-to-noise ratio axis : Axis along which the mean is to be computed. By default ax 2 min read sciPy stats.describe() function | Python scipy.stats.describe(array, axis=0) computes the descriptive statistics of the passed array elements along the specified axis of the array. Parameters : array: Input array or object having the elements to calculate the statistics. axis: Axis along which the statistics is to be computed. By default a 2 min read Like