Constrained random points on a circle: Difference between revisions

Content added Content deleted
m (→‎{{header|Perl 6}}: formatting, omit useless semicolons)
(Attempted a clearer task description)
Line 1:
{{task|Probability and statistics}}
TheGenerate task100 is<x,y> tocoordinate generatepairs asuch streamthat ofx 100and uniformlyy distributedare randomintegers pointssampled (x,yfrom integerthe pairs)uniform thatdistribution liewith inthe acondition circularthat disc<math>10 at\leq 10\sqrt{ tox^2 15+ unitsy^2 from} its\leq center;15 and</math>. thenThen display/plot them. toThe showoutcome should be a "fuzzy" circle. The actual number of points plotted may be less than 100, becausegiven that some willpairs may be generated more than overlaponce.
 
There are several possible approaches, dependingto onaccomplish your languagethis. OneHere isare simplytwo topossible generate random pairs of integers and filter out those that don't satisfy the equationalgorithms.
 
1) Generate random pairs of integers and filter out those that don't satisfy this condition:
: <math>10 \leq \sqrt{ x^2 + y^2 } \leq 15</math>
 
: :<math>10 \leq \sqrt{ x^2 + y^2 } \leq 15 </math>.
Another is to precalculate the set of all possible points (there are 404 of them) and select from this set. Yet another is to use real-valued polar coordinates then snap to integer Cartesian coordinates. I'm sure there are others.
 
2) Precalculate the set of all possible points (there are 404 of them) and select randomly from this set.
 
=={{header|D}}==