作者ljuyentintho (小刘)
看板MATLAB
标题[问题]统计分配转换问题
时间Fri Jun 3 00:27:47 2016
程式码如下:
j=6;
a=2;
b=3;
random = unidrnd(b,1,a);
random = repmat(random,j,1);
random = random(:);
randnum = rand(b,j);
str=repmat('B',a*j,1);
secnum=repmat(1:a,j,1);
secnum=secnum(:);
thirdnum=repmat(1:j,1,a)';
temp=cellstr([str,num2str(random),num2str(secnum),num2str(thirdnum)]);
class7=regexprep(temp,' ','');
B=10*randnum(sub2ind([b,j],random,thirdnum));
这段是别人帮我写的
目前会产生一段a*j的均匀乱数值
想请问的是如果我把randnum = rand(b,j);这段
改成randnum = randn(b,j);
这样就应该是常态分配了.......吧
如果不是请指正
另外如果是的话
该怎麽让产生的常态分配乱数没有负值呢?
谢谢好心的大大
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 140.114.54.170
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/MATLAB/M.1464884870.A.377.html
1F:→ celestialgod: randn产生出来的乱数直接加绝对值就好了吧 06/03 01:30
2F:→ ljuyentintho: 加绝对值output就不是常态了 06/03 01:32
3F:推 sin55688: 平移? 06/03 12:31
4F:→ ljuyentintho: 我是这样想的 但不知平移多少 06/03 18:27
5F:→ celestialgod: 喔喔 我误会你意思了 我以为你要half normal 06/03 20:01
6F:→ celestialgod: 变异数是1的话 平移4小於0的机率是0.00003 06/03 20:02
7F:→ celestialgod: 4.5是0.000003,5是0.0000003 看你大概要什麽范围 06/03 20:02
8F:→ celestialgod: 不幸出现零就重抽 重抽机率低 06/03 20:03
9F:→ celestialgod: 这样也不完全是常态就是 大概只有尾部一点点 06/03 20:03
10F:→ celestialgod: 不然你就要找truncated normal了 06/03 20:03
11F:推 simon552614: truncated normal 刚好之前上课写过 06/04 02:05