Home > Backend Development > Python Tutorial > What is std in python

What is std in python

(*-*)浩
Release: 2019-07-09 10:34:34
Original
17353 people have browsed it

std() function is the standard deviation of middle school and high school

What is std in python

##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
Copy after login
For more Python related technical articles, please visit the

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template