sciPy stats.sem() function | Python

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:

filter_none

edit
close

play_arrow

link
brightness_4
code

# 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)) 

chevron_right


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


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.