+4 votes
in Programming Languages by (17.9k points)
I want to calculate the standard error of the mean of elements of a given list. Is there any Python function for it?

1 Answer

+4 votes
by (28.5k points)

The sem() function of scipy.stats can be used to calculate the standard error of the mean (or standard error of measurement) of the values in the input array.

Here is an example:

>>> from scipy import stats as st

>>> import numpy as np

>>> a=np.random.random(10)

>>> a

array([0.23840975, 0.68159684, 0.747814  , 0.27296423, 0.07580225,

       0.8901718 , 0.83292882, 0.03398631, 0.29072783, 0.22097503])

>>> se = st.sem(a)

>>> se

0.10247672761861855


...