std() function is the standard deviation of middle school and high school
##numpy.std() When finding the standard deviation, the default is Divided by n, it is biased. The method of unbiased sample standard deviation of np.std is to add parameter ddof = 1; (recommended learning: Python video tutorial)
pandas.std() defaults to dividing by n-1, that is, it is unbiased. If you want to be biased like numpy.std(), you need to add the parameter ddof=0, that is, pandas.std(ddof= 0) ;
In statistics, many years of experience have concluded:
If it is the population, the standard deviation formula is divided by n within the square root,If it is a sample, the standard deviation formula is divided by the root sign (n-1). Because we are exposed to a lot of samples, we generally use the square root divided by (n-1). Meaning of the formula: Subtract the average value from all numbers, divide its sum of squares by the number of numbers (or the number minus one), and then take the root sign of the resulting value, which is 1/2 power, and get The number is the standard deviation of this set of numbers. DataFrame's describe() contains std();>>> a array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) >>> np.std(a, ddof = 1) 3.0276503540974917 >>> np.sqrt(((a - np.mean(a)) ** 2).sum() / (a.size - 1)) 3.0276503540974917 >>> np.sqrt(( a.var() * a.size) / (a.size - 1)) 3.0276503540974917
Python Tutorial column to learn!
The above is the detailed content of What is std in python. For more information, please follow other related articles on the PHP Chinese website!