Skip to content
Related Articles

Related Articles

Improve Article

sciPy stats.sem() function | Python

  • Last Updated : 18 Feb, 2019

scipy.stats.sem(arr, axis=0, ddof=0) function is used to compute the standard error of the mean of the input data.

Parameters :
arr : [array_like]Input array or object having the elements to calculate the standard error.
axis : Axis along which the mean is to be computed. By default axis = 0.
ddof : Degree of freedom correction for Standard Deviation.

Results : standard error of the mean of the input data.

Example:




# stats.sem() method 
import numpy as np
from scipy import stats
   
   
arr1 = [[20, 2, 7, 1, 34],
        [50, 12, 12, 34, 4]]
  
arr2 = [50, 12, 12, 34, 4]
  
print ("\narr1 : ", arr1)
print ("\narr2 : ", arr2)
  
print ("\nsem ratio for arr1 : "
       stats.sem(arr1, axis = 0, ddof = 0))
  
print ("\nsem ratio for arr1 : "
       stats.sem(arr1, axis = 1, ddof = 0))
  
print ("\nsem ratio for arr1 : "
       stats.sem(arr2, axis = 0, ddof = 0)) 

Output :

arr1 :  [[20, 2, 7, 1, 34], [50, 12, 12, 34, 4]]

arr2 :  [50, 12, 12, 34, 4]

sem ratio for arr1 :  [10.60660172  3.53553391  1.76776695 11.66726189 10.60660172]

sem ratio for arr1 :  [5.62423328 7.61892381]

sem ratio for arr1 :  7.618923808517841

 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

My Personal Notes arrow_drop_up
Recommended Articles
Page :