Standard deviation in numpy [duplicate]
问题 This question already has answers here : Python: Numpy standard deviation error (3 answers) Closed 4 years ago . Here is my code: import numpy as np print(np.std(np.array([0,1]))) it produces 0.5 I am confident that this is incorrect. What am I doing wrong? 回答1: By default, numpy.std returns the population standard deviation, in which case np.std([0,1]) is correctly reported to be 0.5 . If you are looking for the sample standard deviation, you can supply an optional ddof parameter to std() :