Re: [問題] 產生random vector已回收

看板MATLAB作者 (Achilles)時間16年前 (2009/03/16 08:51), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串4/7 (看更多)
※ 引述《microball (無華之果)》之銘言: : theda = 2*pi.*rand(1000,1); : phi = pi.*rand(1000,1) ; : RandR = zeros(1000,3); : RandR(:,1) = sin(phi-pi/2).*cos(theda); : RandR(:,2) = sin(phi-pi/2).*sin(theda); : RandR(:,3) = cos(phi-pi/2); : 希望有對XD 很不幸, 這個也不對. 你雖然把 theda, phi 兩個角度取成 uniform on [0, 2pi] and [0, pi] 但是 differential area element 是 d A = r^2 * sin(phi) *d(theta) * d(phi). 就舉個反例吧: 當 phi = pi/2, 你舉的例子, 點會落在 (0,0,1) exactly on point, 但是, 當 phi = pi, 點卻是分布在 (cos(theda), sin(theda), 1) 你覺得這兩個地方會有相同的 pdf 嗎? -- 趙客縵胡纓,吾鉤霜雪明。銀鞍照白馬,颯沓如流星。 十步殺一人,千里不留行。是了拂衣去,深藏身與名。 閑過信陵飲,脫劍膝前橫。將炙啖朱亥,持觴勸侯贏。 三杯吐然諾,五嶽倒為輕。眼花耳熱後,意氣素霓生。 就趙揮金錘,邯鄲先震驚。千秋二壯士,烜赫大梁城。 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 76.171.164.195

03/17 07:23, , 1F
啊 對 謝謝提醒^^
03/17 07:23, 1F
文章代碼(AID): #19lQAcgK (MATLAB)
文章代碼(AID): #19lQAcgK (MATLAB)