问题描述
使用Python,假设我正在运行已知数量的项目I
,并且能够计时处理每个t
所需的时间,以及运行所花费的时间总计T
和到目前为止已处理的项目数c
.我目前正在计算运行中的平均值A = T / c
,但是如果说单个项目花费的时间特别长(几秒钟而不是几毫秒),则可能会造成偏差.
Using Python, assume I'm running through a known quantity of items I
, and have the ability to time how long it takes to process each one t
, as well as a running total of time spent processing T
and the number of items processed so far c
. I'm currently calculating the average on the fly A = T / c
but this can be skewed by say a single item taking an extraordinarily long time to process (a few seconds compared to a few milliseconds).
我想展示一个运行中的标准偏差.在不保存每个t
记录的情况下该如何做?
I would like to show a running Standard Deviation. How can I do this without keeping a record of each t
?
推荐答案
我使用,它可以提供更准确的结果.该链接指向 John D. Cook的概述.这是其中的一段,总结了为什么它是首选方法:
I use Welford's Method, which gives more accurate results. This link points to John D. Cook's overview. Here's a paragraph from it that summarizes why it is a preferred approach:
这篇关于计算流中的标准偏差的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!