📄 index4log_sampling1.m
字号:
function index=index4log_sampling1(nsamp,ntr,param)
% Function creates index vector to access log data for "random modeling"
% Creates a stepsize with a distribution approximately proportional to 1/stepsize
% and a direction which changes in such a way that
% "mean(positive steps - negative steps)" is approximately "avinc".
% Unlike "index4log_sampling", indices that exceed "param.maxindex" are
% "reflectde back (e.g. index "index" > "param.maxindex" is changed
% to 2*param.maxindex - index.
% Written by: E. R.: February 16, 2004
% Last updated:
%
% index=index4log_sampling1(nsamp,ntr,param)
% INPUT
% nsamp number of rows of index matrix
% ntr number of columns of index matrix
% param structure with parameters to determine the way the indices are computed
% 'mininc' minimum step from one index to the next (1 or greater)
% 'maxinc' maximum step
% 'avinc' average step to take
% 'maxindex' largst index
% OUTPUT
% index indices [1,maxindex]
% Create a sequence of step with lengths between "mnistep" and "maxinc"
steps=ss_random_thicknesses(ntr*nsamp,1,param.mininc,param.maxinc);
steps=round(steps);
% Revert some of the steps to achieve a average step size of "avinc"
mstep=mean(steps);
alpha=(param.avinc/mstep+1)/2;
rnd=rand(ntr*nsamp,1);
idx=rnd > alpha;
steps(idx)=-steps(idx);
index=cumsum(steps);
maxindex=param.maxindex;
temp=round(maxindex*rand(1,ntr));
index=reshape(index,nsamp,ntr)+temp(ones(nsamp,1),:);
index=mod(index(:),2*maxindex-1)+1;
idx=find(index > maxindex);
index(idx)=2*maxindex-index(idx);
index=reshape(index,nsamp,ntr);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -