Geometric mean for a specific time intervals

1 vue (au cours des 30 derniers jours)
Charles Martineau
Charles Martineau le 1 Juin 2012
Hi all,
say that I have a matrix (NX2) where the first column's elements are the number of seconds (since midnight) and the second column is stock returns associated to associated to the seconds. How can I use the function geomean and compute the geometric returns for a specific time interval? Say the geomean returns at every minute interval? The problem is that I might have say 4 stock returns in some specific minute interval and sometime 10 returns in another interval. If I extract all the trades by minutes, the numbers of returns registered in each minute interval will not be the same. Thank you!
  2 commentaires
Oleg Komarov
Oleg Komarov le 1 Juin 2012
Please do NOT delete answered questions.
Charles Martineau
Charles Martineau le 1 Juin 2012
Hi Oleg, sorry I did deleted my previous question by mistake!

Connectez-vous pour commenter.

Réponse acceptée

Andrei Bobrov
Andrei Bobrov le 1 Juin 2012
data = [(1:130)', randi(100,130,1)];
out = accumarray(ceil(data(:,1)/60),data(:,2),[],@geomean,NaN);

Plus de réponses (1)

Charles Martineau
Charles Martineau le 1 Juin 2012
Andrei thanks a lot! I didn't know about the accumarray function. I should have been more clear though in my question: I have multiple days stack on over the other. For intance: all stock returns per second for Sept.02 and then Sept.03. I have to find out how not to accumulate geomean returns combining multiple days at the same time.

Catégories

En savoir plus sur Descriptive Statistics dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by