24小时热门版块排行榜    

查看: 621  |  回复: 10
当前主题已经存档。
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

woshilsh

荣誉版主 (职业作家)

优秀版主

[交流] 【求助】Matlab随机数生成问题【已完成】

我想生成一个三维的数据,

数据服从双峰高斯分布,要400个点,中心在(1,0,0)和(-1,0,0)

试了几次,搞不定,那位大侠知道,交流下!

[ Last edited by nono2009 on 2009-9-23 at 22:10 ]
回复此楼

» 猜你喜欢

[center][url=http://www.91cool.net/][img]http://id.91cool.net/sign/?name=小木虫印&say=各位版主辛苦了![/img][/url][/center]
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

woshilsh

荣誉版主 (职业作家)

优秀版主

★ ★
sunxiao(金币+2,VIP+0):友情鼓励一下,呵呵 7-4 01:24
引用回帖:
Originally posted by hitzhang at 2009-7-2 18:26:


>> MU = [-1 0;1 0];
>> SIGMA = cat(3,[.5 0;0 .5],[.5 0;0 .5]);
>> p = ones(1,2)/2;
>> obj = gmdistribution(MU,SIGMA,p);
>> ezsurf(@(x,y)pdf(obj,[x y]),[-2:.1:2 ...

按照张兄的程序是不是应该这就是三维数据?

y=pdf(obj,[x y]);
[[-2:.1:2]' [-2:.1:2]' y']?

要不还是二维数据啊

[ Last edited by woshilsh on 2009-7-2 at 20:11 ]
[center][url=http://www.91cool.net/][img]http://id.91cool.net/sign/?name=小木虫印&say=各位版主辛苦了![/img][/url][/center]
7楼2009-07-02 20:02:01
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
查看全部 11 个回答

mininurse

金虫 (正式写手)

★ ★ ★ ★
小木虫(金币+0.5):给个红包,谢谢回帖交流
woshilsh(金币+3,VIP+0):感谢,但是你生成的只是随机数,不一定复合双峰高斯分布的,期待继续关注 7-2 12:36
不知道这样做对不对

%%%% generate the random x, y, z dataset for the first Gaussian
A=randn(400,1,3);
X1=A(:,:,1)+1; %% x axis dataset
Y1=A(:,:,2);  %% y axis dataset
Z1=A(:,:,3);  %% z axis dataset

%%%% generate the random x, y, z dataset for the second Gaussian
B=randn(400,1,3);
X2=B(:,:,1)-1; %% x axis dataset
Y2=B(:,:,2);  %% y axis dataset
Z2=B(:,:,3);  %% z axis dataset

%% the outcome

newX=(X1+X2)/2; %% x dataset for the new mutual gaussian distribution
newY=(Y1+Y2)/2; %% y dataset for the new mutual gaussian distribution
newZ=(Z1+Z2)/2; %% z dataset for the new mutual gaussian distribution
引用回帖:
Originally posted by woshilsh at 2009-7-1 19:21:
我想生成一个三维的数据,

数据服从双峰高斯分布,要400个点,中心在(1,0,0)和(-1,0,0)

试了几次,搞不定,那位大侠知道,交流下!

[ Last edited by mininurse on 2009-7-2 at 09:06 ]
2楼2009-07-02 08:55:44
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

woshilsh

荣誉版主 (职业作家)

优秀版主

引用回帖:
Originally posted by mininurse at 2009-7-2 08:55:
不知道这样做对不对

%%%% generate the random x, y, z dataset for the first Gaussian
A=randn(400,1,3);
X1=A(:,:,1)+1; %% x axis dataset
Y1=A(:,:,2);  %% y axis dataset
Z1=A(:,:,3);  %% z axis ...

偶需要的是服从双峰高斯分布的数据,你这个思路对了,可是不一定服从正太分布
[center][url=http://www.91cool.net/][img]http://id.91cool.net/sign/?name=小木虫印&say=各位版主辛苦了![/img][/url][/center]
3楼2009-07-02 12:36:42
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

hitzhang

木虫 (正式写手)

★ ★ ★ ★ ★ ★
小木虫(金币+0.5):给个红包,谢谢回帖交流
woshilsh(金币+5,VIP+0):期待张兄有空再看看,三维数据咋弄,如何得到 7-2 19:54
引用回帖:
Originally posted by woshilsh at 2009-7-1 19:21:
我想生成一个三维的数据,

数据服从双峰高斯分布,要400个点,中心在(1,0,0)和(-1,0,0)

试了几次,搞不定,那位大侠知道,交流下!

[ Last edited by woshilsh on 2009-7-2 at 16:34 ]

>> MU = [-1 0;1 0];
>> SIGMA = cat(3,[.5 0;0 .5],[.5 0;0 .5]);
>> p = ones(1,2)/2;
>> obj = gmdistribution(MU,SIGMA,p);
>> ezsurf(@(x,y)pdf(obj,[x y]),[-2:.1:2],[-2:.1:2])
>>
4楼2009-07-02 18:26:05
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
普通表情 高级回复 (可上传附件)
信息提示
请填处理意见