Geometric mean for a specific time intervals
조회 수: 1 (최근 30일)
이전 댓글 표시
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
채택된 답변
Andrei Bobrov
2012년 6월 1일
data = [(1:130)', randi(100,130,1)];
out = accumarray(ceil(data(:,1)/60),data(:,2),[],@geomean,NaN);
댓글 수: 0
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Descriptive Statistics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!