sciPy stats.gmean() function | Python
scipy.stats.gmean(array, axis=0, dtype=None) calculates the geometric mean of the array elements along the specified axis of the array (list in python).
It’s formula –
array: Input array or object having the elements to calculate the geometric mean.
axis: Axis along which the mean is to be computed. By default axis = 0
dtype: It sets the type of returned element.
Returns : Geometric mean of the array elements based on the set parameters.
Geometric Mean is : 4.32674871092
Code #2: With multi-dimensional data
Geometric Mean is : [ 2.81731325 4.55901411 7.89644408] Geometric Mean is with default axis = 0 : [ 2.81731325 4.55901411 7.89644408] Geometric Mean is with default axis = 1 : [ 4.32674871 4.16016765 5.01329793 5.24148279]
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course