Results 1 to 5 of 5

Math Help - Calculating Skewness using s non iteratice aproach

  1. #1
    Newbie
    Joined
    Aug 2007
    Posts
    8

    Calculating Skewness using s non iteratice aproach

    Hi guys,

    A while back I was kindly helped with a non iterative algorithm to calculate a weighted average and its variance outlined here http://www.mathhelpforum.com/math-he...-variance.html I need to add Skew now.

    From Skewness - Wikipedia, the free encyclopedia Skewness is given as the 3rd moment about the mean divided by standard deviation. Thanks to JakeD I have an algorithm to calculate the weighted average and variance (so SD too) that uses non iterative techniques (you can see that in the first thread). Keeping track of the mean as you go along is trivial. I feel there must be a small modification that could be made to accumulate the 3rd moment but to be frank I think its beyond me. (a simple code head!) I was hoping one of you maths guys might be able to help again. This needs to work on a 'stream' of time series data so I need to be able to calculate as a new piece of data rather than process the whole series each time. Hope someone can help.

    Thanks in advance,
    Nick.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Newbie
    Joined
    Aug 2007
    Posts
    8
    Am I right in thinking that the variance is the second moment and that the skewness is the third moment?

    Here is the algorithm I used for variance and I wonder if simply summing ^3's rather than ^2's will give me the 3rd moment? I feel it should be quite easy but it's still rather beyond me.


    mean_old = 0;
    mean_new = 0;
    sum = 0;
    wgt_old = 0;
    wgt_new = 0;

    foreach x in data and w in weights:
    wgt_new = wgt_old + w;
    mean_new = (wgt_old*mean_old + w*x)/wgt_new;
    sum = sum + wgt_old*mean_old^2 + w*x^2 - wgt_new*mean_new^2;
    wgt_old = wgt_new;
    mean_old = mean_new;
    end for;
    variance = sum/wgt_new;
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by BlowFish View Post
    Am I right in thinking that the variance is the second moment and that the skewness is the third moment?
    No the variance is the CENTRAL second moment, that is:

    var=E[(x-mean)^2)]

    Skewdness is the normalised third CENTRAL moment:

    skew= E[(x-mean)^3)]/sigma^3

    RonL
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Newbie
    Joined
    Aug 2007
    Posts
    8
    Thanks Ron - My knowledge of this stuff is weak, its hard for me to decipher not completely understanding the terms. I am still thinking that this should be quit doable by modifying the original algorithm.
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Newbie
    Joined
    Aug 2007
    Posts
    8
    Well still struggling on with this but could use some help if any one is up to it? assuming everything is initialised to zero. I have

    foreach x in data and w in weights:
    wgt_new = wgt_old + w;
    mean_new = (wgt_old*mean_old + w*x)/wgt_new;
    sum = sum + wgt_old*mean_old^2 + w*x^2 - wgt_new*mean_new^2;
    sumcm = sumcm + wgt_old*mean_old^3 + w*x^3 - wgt_new*mean_new^2;
    wgt_old = wgt_new;
    mean_old = mean_new;
    end for;
    variance = sum/wgt_new;
    SD = sqrt(variance);
    sumSD3 = SumSD3 + SD^3;

    CM3 = sumcm/sumSD3/wgt_new


    I am assuming the formula for weighted skew found here 8.2.8 Weighted Samples is correct? I am assuming xbar is the mean though am unsure why they refer to it that way?
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Skewness
    Posted in the Advanced Statistics Forum
    Replies: 2
    Last Post: July 3rd 2010, 06:05 AM
  2. Replies: 5
    Last Post: February 22nd 2010, 02:41 PM
  3. skewness
    Posted in the Advanced Statistics Forum
    Replies: 1
    Last Post: June 13th 2009, 07:17 PM
  4. Skewness from two PGF
    Posted in the Advanced Statistics Forum
    Replies: 1
    Last Post: October 25th 2008, 01:49 PM
  5. Help Calculating Skewed Deviation Skewness
    Posted in the Advanced Statistics Forum
    Replies: 4
    Last Post: September 25th 2008, 10:40 PM

Search Tags


/mathhelpforum @mathhelpforum