首页
/
每日頭條
/
教育
/
如何用python算方差
如何用python算方差
更新时间:2025-07-29 13:10:09

  用python算方差可以借助numpy的向量運算來求更快速:

  import numpy

  narray=numpy.array(nlist)

  sum1=narray.sum()

  narray2=narray*narray

  sum2=narray2.sum()

  mean=sum1/N

  var=sum2/N-mean**2

Comments
Welcome to tft每日頭條 comments! Please keep conversations courteous and on-topic. To fosterproductive and respectful conversations, you may see comments from our Community Managers.
Sign up to post
Sort by
Show More Comments
Copyright 2023-2025 - www.tftnews.com All Rights Reserved