Generate N random uniformly distributed points in the d-ball

Answers (2)

d = 3
n = 10000;
% s is (d x n), n points in unit d-ball
s = randn(d,n);
r = rand(1,n).^(1/d);
c = r./sqrt(sum(s.^2,1));
s = bsxfun(@times, s, c);
https://uk.mathworks.com/matlabcentral/fileexchange/108374-uniformly-distributed-points

Categories

Find more on Random Number Generation in Help Center and File Exchange

Products

Release

R2018a

Asked:

on 10 Jan 2019

Answered:

on 20 Mar 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!