1 Star 0 Fork 0

马婧/Q-Learning-Algorithm-Implementation-in-MATLAB

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
RandomPermutation.m 858 Bytes
一键复制 编辑 原始数据 按行查看 历史
function y=RandomPermutation(A)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% return random permutation of matrix A
% unlike randperm(n) that give permutation of integer 1:n only,
% RandomPermutation rearrange member of matrix A randomly
% This function is useful for MonteCarlo Simulation, Bootstrap sampling, game, etc.
%
% Copyright Kardi Teknomo(c) 2005
% (http://people.revoledu.com/kardi/)
%
%
% example:
% A=magic(3)
% RandomPermutation(A)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if nargin<1,
A = [ 2, 1, 5, 3];
end
[r,c]=size(A);
b=reshape(A,r*c,1); % convert to column vector
x=randperm(r*c); % make integer permutation of similar array as key
w=[b,x']; % combine matrix and key
d=sortrows(w,2); % sort according to key
y=reshape(d(:,1),r,c); % return back the matrix
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/majingself/Q-Learning-Algorithm-Implementation-in-MATLAB.git
git@gitee.com:majingself/Q-Learning-Algorithm-Implementation-in-MATLAB.git
majingself
Q-Learning-Algorithm-Implementation-in-MATLAB
Q-Learning-Algorithm-Implementation-in-MATLAB
master

搜索帮助