Re: [問題] 產生random vector已回收
※ 引述《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
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 4 之 7 篇):
MATLAB 近期熱門文章
PTT數位生活區 即時熱門文章