This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rhettinger
Recipients rhettinger, steven.daprano
Date 2022-01-04.17:04:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <[email protected]>
In-reply-to
Content
The existing code makes two passes, one to compute the mean and another to compute the sum of squared differences from the mean.  A consequence of making two passes is that iterator inputs must be converted to a list before processing.  This throws away the memory saving advantages of iterators. 

The ostensible reason for the two pass code is that the single pass variant is numerically unstable when implemented with floating point accumulators.  However, this code uses fractions throughout, so the accumulation is exact.

Changing to a single pass saves memory, doubles the speed, and simplifies the upstream code in variance(), pvariance(), stdev(), and pstdev().
History
Date User Action Args
2022-01-04 17:04:05rhettingersetrecipients: + rhettinger, steven.daprano
2022-01-04 17:04:05rhettingersetmessageid: <[email protected]>
2022-01-04 17:04:05rhettingerlinkissue46257 messages
2022-01-04 17:04:05rhettingercreate