Partition function in Matlab - is there something missing in my code?
Show older comments
Can anyone see if there is something wrong in my matlab code? My objective is to replicate this formula: http://i.stack.imgur.com/JANLf.jpg q can take value 1,2,3 and 5. I constructed my vector Xt where each element are a cumulative sum of log(1+return) at each time (t) - for stock returns - first element is normalized to log(1).
Then to compute each element Sq(T,delta t) for the four values of q this is my matlab code:
for j=1:length(dt);
E=Xt(1:dt(j):end);
EE=diff(E(2:end));
EEE=diff(E(1:end-1));
Sqone(j)=sum(abs(EE-EEE).^1);
Sqtwo(j)=sum(abs(EE-EEE).^2);
Sqthree(j)=sum(abs(EE-EEE).^3);
Sqfive(j)=sum(abs(EE-EEE).^5); end;
Is there something wrong in the code above? I am asking this because I know there is something wrong since I am not getting the expected results. I am convinced that it is due to my code posted above.
the vector dt is a vector that goes from 1 to high number - depending on the size of Xt. But my vector dt is not the problem.
Thank you for all your help!
Accepted Answer
More Answers (2)
Charles Martineau
on 5 Jun 2012
0 votes
4 Comments
Andrei Bobrov
on 5 Jun 2012
No, this is a complete solution. 'Sq' - handle function
Charles Martineau
on 5 Jun 2012
Andrei Bobrov
on 5 Jun 2012
What is it 'dt' and 'Xt'. Please give simple numeric example.
Charles Martineau
on 5 Jun 2012
Charles Martineau
on 5 Jun 2012
Categories
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!