Post Reply 
No σ for you!
Yesterday, 01:04 AM
Post: #24
RE: No σ for you!
(11-26-2024 08:12 PM)dm319 Wrote:  
(11-25-2024 03:58 PM)carey Wrote:  It works, but working with absolute values in subsequent equations becomes unwieldly.

In what way?

Here, I look at computation part of deviation calculations, not their merit.

With absolute deviation, you can't start sum deviations without a final mean.
This implied we may need to scan data set in 2 passes.

Also, adding or removal a data point may require recalculations of all deviations.
(we can keep data sorted, but that is also expensive, both time and space)

With variance, you can add or remove element, for instant O(1) update.
If you only need {µ, σ} statistics, you don't even need to store the data.

You don't even need a 'final' mean, and can do running mean and variance.

John D. Cook, Accurately computing running variance

Σ defined from i = 1 to k-1
Let m = Σ(xi) / (k-1)
Let S = Σ(xi - m)^2

Now, we add a data xk to the mix, for new mean and variance.

mk = ((k-1)*m + xk)/k = (k*m + (xk-m))/k

Running mean: mk = m + z, where z = (xk - m) / k

Sk = Σ(xi - mk)^2     + (xk - mk)^2
     = Σ((xi-m)-z)^2    + (xk - mk)^2
     = S + (k-1)*z^2   + (xk - mk)^2            -- NOTE: Σ(xi - m) = 0
     = S +  k*z  * z      + (xk - mk)^2 - z^2
     = S + (xk - m) * z + (xk - m) * (xk - mk - z)

Running sample variance: Sk = S + (xk - m) * (xk - mk) --> s^2 = Sk / (k−1)

Formulas also work when we remove xk from data set. (back solve {m, S} from {mk, Sk})
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
No σ for you! - naddy - 11-21-2024, 03:51 PM
RE: No σ for you! - KeithB - 11-21-2024, 04:08 PM
RE: No σ for you! - AnnoyedOne - 11-21-2024, 04:48 PM
RE: No σ for you! - KeithB - 11-21-2024, 06:02 PM
RE: No σ for you! - rprosperi - 11-22-2024, 01:07 PM
RE: No σ for you! - Paul Dale - 11-21-2024, 09:41 PM
RE: No σ for you! - Albert Chan - 11-21-2024, 10:03 PM
RE: No σ for you! - KeithB - 11-22-2024, 02:27 PM
RE: No σ for you! - KeithB - 11-22-2024, 02:54 PM
RE: No σ for you! - carey - 11-23-2024, 08:09 AM
RE: No σ for you! - Albert Chan - 11-23-2024, 12:38 PM
RE: No σ for you! - HPing - 11-24-2024, 06:48 PM
RE: No σ for you! - Albert Chan - 11-24-2024, 08:59 PM
RE: No σ for you! - Nihotte(lma) - 11-24-2024, 06:00 PM
RE: No σ for you! - naddy - 11-24-2024, 07:13 PM
RE: No σ for you! - dm319 - 11-25-2024, 12:54 PM
RE: No σ for you! - carey - 11-25-2024, 03:58 PM
RE: No σ for you! - EdS2 - 11-25-2024, 04:01 PM
RE: No σ for you! - carey - 11-25-2024, 04:49 PM
RE: No σ for you! - dm319 - 11-26-2024, 08:12 PM
RE: No σ for you! - dm319 - 11-26-2024, 10:58 PM
RE: No σ for you! - carey - Yesterday, 12:53 AM
RE: No σ for you! - Albert Chan - Yesterday 01:04 AM
RE: No σ for you! - Albert Chan - Yesterday, 01:09 PM
RE: No σ for you! - carey - Yesterday, 06:17 PM
RE: No σ for you! - KeithB - 11-25-2024, 05:54 PM
RE: No σ for you! - dm319 - Yesterday, 07:56 PM
RE: No σ for you! - carey - Yesterday, 08:52 PM



User(s) browsing this thread: 8 Guest(s)