views:

316

answers:

5

I am trying to determine the volatility of a rank.

More specifically, the rank can be from 1 to 16 over X data points (the number of data points varies with a maximum of 30).

I'd like to be able to measure this volatility and then map it to a percentage somehow.

I'm not a math geek so please don't spit out complex formulas at me :)

I just want to code this in the simplest manner possible.

Thanks!

G-Man

+3  A: 

I think the easiest first pass would be Standard Deviation over X data points.

EBGreen
+2  A: 

I think that Standard Deviation is what you're looking for. There are some formulas to deal with, but it's not hard to calculate.

Dana the Sane
+2  A: 

This link may help to explain how to calculate Standard Deviation in simple terms: How To Calculate Standard Deviation

HackedByChinese
Worked perfectly and wow - that was easy to code too :)
GeoffreyF67
+1  A: 

If you want something really simple you could take the average of the absolute differences between successive ranks as volatility. This has the added bonus of being recursive. Us this for initialisation:

double sum=0;
for (int i=1; i<N; i++)
{
    sum =abs(ranks[i]-ranks[i-1];
}
double volatility = sum/N;

Then for updating the volatility if a new rank at time N+1 is available you introduce the parameter K where K determines the speed with which your volatility measurement adapts to changes in volatility. Higher K means slower adaption, so K can be though of as a "decay time" or somesuch:

double K=14 //higher = slower change in volatility over time.
double newvolatility;
newvolatility = (oldvolatility * (K-1) + abs(rank[N+1] - rank[N]))/K;

This is also known as a moving average (of the absolute differences in ranks in this case).

jilles de wit
+1  A: 

Given that you have a small sample set (you say a maximum of 30 data points) and that the standard deviation is easily affected by outliers, I would suggest using the interquartile range as a measure of volatility. It is a trivial calculation and would give a meaningful representation of the data spread over your small sample set.

Mark Lavin