全部版块 我的主页
论坛 提问 悬赏 求职 新闻 读书 功能一区 经管百科 爱问频道
1657 0
2010-04-10
要求是这样的:
1.Generate 20 or more random numbers using your LCG
function:U
1
,...,U
20
.
2.Pick one of these 20 numbers with equal probability,
1/20.This requires generating another random number
from a different stream.Assign the picked random
number from the U stream,say U
3
,to W,i.e.,W
1
=U
3
.
3.Replace the random number picked from the first
stream,say U
3
,with the next random number in the
sequence,i.e.,U
21
.
4.Repeat steps 2-3.This results in a shuffled sequence of
random numbers,W,of the initial sequence,U.



下面是我编的程序,我知道存在很大的问题,由于初学matlab实在是不知道怎么改进,
特别是当循环需要用上底标,而取矩阵值时也需要,而这怎么弄,还请大侠知道哈~~~

function [w]= Shuffling(n)
m=rand(1,n);
for i=1:n-20;
   k=m(1:20);
   k=subs(k,k(3),m(20+i));
  k=k(randperm(20));
end
w=sum(k(3));
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群