[Thread Prev][Thread Next][Index]

Re: [ferret_users] 21 yr running correlation



Thank you all for this effort. This may be useful for many others as well.

Happy Ferreting

On Wed, Aug 29, 2018 at 10:15 PM Ryo Furue <furue@xxxxxxxxxx> wrote:
Hi Ferret users,

On Wed, Aug 29, 2018 at 11:57 AM Ryo Furue <furue@xxxxxxxxxx> wrote:
Your method utilizes the identity

mean{ [a - mean(a)]^2}
= mean(a^2) - [mean(a)]^2

so that the operation mean() is applied only once in each term.  That's elegant.

Currently, I need a "running skewness", which I think I can calculate applying your method.

For a record, I describe how one can calculate it.

To extend Andrew's method, we first need a formula to calculate the third moment without nested applications of mean(). The formula is

mean{ [a - mean(a)]^3 }
 = mean{ a^3 - 3 a^2 mean(a) + 3 a [mean(a)]^2 - [mean(a)]^3 }
 = mean(a^3) - 3 mean(a^2) mean(a) + 3 mean(a) [mean(a)]^2 - [mean(a)]^3
 = mean(a^3) - 3 mean(a^2) mean(a) + 2 [mean(a)]^3

So, my Ferret code looks like:

define symbol avr_ t=@SBX:13

let squared = a * a
let cubed   = a * a * a

let mean         = a[($avr_)]
let mean_squared = squared[($avr_)]
let mean_cubed   = cubed[($avr_)]

let second = mean_squared - mean * mean
let stddev = second^0.5

let third = mean_cubed - 3 * mean_squared * mean \
            + 2 * (mean^3)

let skew = third / (stddev^3)

Cheers,
Ryo
 


--


REGARDS

Saurabh Rathore
Research Scholar (PhD.)
Centre For Oceans, Rivers, Atmosphere & Land Science Technology
Indian Institute Of Technology, Kharagpur
contact :- 91- 8345984434

[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement