How to concatenate data points
古いコメントを表示
I am trying to do a Monte Carlo analysis where I have to concatenate some data points and I'm kind of stuck on how to do that.
My code goes something like this (edited for length):
1) I have a 4-column data vector with ~30,000 rows. The columns are year, month, day, and precipitation amount.
2) I fit a GEV distribution to the precipitation vector and determine the 50% quantile
3) I reshuffle the data in 2-day chunks using mixed odd or even parity and re-fit the GEV and redetermine the quantile.
4) I repeat step 3 1000 times.
I have most everything else working except for how to concatenate my data points into 2-day chunks. I'm using a random number generator to randomly select odd or even parity but I'm not sure of the syntax to use for how to make the program shuffle them in groups of 2.
回答 (1 件)
I am a little uncertain that this is what you want. But just to get started is this solving the actual problem?
A = reshape(1:24,8,3) % Given array.
% Now reorder rows by groups of two.
B = mat2cell(A,ones(1,4)*2,3);
B = B(randperm(4));
B = vertcat(B{:})
If so then a faster approach would be:
A = reshape(1:24,8,3) % Given array.
% Now reorder rows by groups of two.
m = size(A,1);
C = reshape(1:m,2,m/2);
C = C(:,randperm(m/2));
C = A(C(:),:)
カテゴリ
ヘルプ センター および File Exchange で Noncentral Chi-Square Distribution についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!