Generate gaussian random points in 3D space with a given mean position.
조회 수: 7 (최근 30일)
이전 댓글 표시
Given a point in 3D space, m = (x,y,z), I would like to generate a series of gaussian random points with a mean position of m and a given standard deviation, s (s is the same for all directions). Any ideas on the easiest way to do this?
My first thought is to pick random unit vectors, d=(dx,dy,dz) with equal probability of pointing in any direction(I think this is equivalent to randomly picking points on a unit sphere). Then get random radii with a gaussian distribution of mean=0 and std=s. The random points then become p=m+r*d; This seems like a lot of work and I wonder if anyone has a more clever way to do this.
Thanks, Justin
댓글 수: 0
답변 (1개)
Iman Ansari
2013년 6월 26일
m = [2 0 2];
s = 1;
n = bsxfun(@plus,m,s.*randn(100,3));
plot3(n(:,1),n(:,2),n(:,3),'.r')
M = mean(n,1)
S = std(n,1)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Random Number Generation에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!