function p = circle_nonuniform ( n ) %% CIRCLE_NONUNIFORM returns sample points from a circle. % % Discussion: % % This routine returns N points sampled nonuniformly at random % from within the unit circle. % % Modified: % % 20 May 2006 % % Author: % % John Burkardt % % Parameters: % % Input, integer N, the number of points to generate. % % Output, real P(2,N), the sample points. % % % Step 1: Generate N points in the unit circle. % (Generate N normally distributed points. % Normalize them (now they lie on the circumference). % Assign a radius.) % p(1:2,1:n) = randn(2,n); p_norm(1:n) = sqrt ( dot ( p, p, 1 ) ); r(1:n) = rand(1,n); for i = 1 : 2 p(i,1:n) = sqrt ( sqrt ( r(1:n) ) ) .* p(i,1:n) ./ p_norm(1:n); end