permutedata.m
来自「Mathematical Methods by Moor n Stiling.」· M 代码 · 共 27 行
M
27 行
function xp = permutedata(x,type)
%
% Randomly permute the columns of the data x.
%
% function xp = permutedata(x,type)
%
% x = data to permute
% type=type of permutation
% type=1: Choose a random starting point, and go sequentially
% type=2: random selection without replacement (not really a permutation)
%
% xp = permuted x
% Copyright 1999 by Todd K. Moon
[n,M] = size(x);
switch type
case 1,
start = floor(M*rand+1);
xp = x(:,start:end);
xp = [xp x(:,1:start-1)];
case 2,
randind = floor(M*rand(1,M)+1);
xp = x(:,randind);
otherwise,
error('invalid permutation type')
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?