11 lines
726 B
Text
11 lines
726 B
Text
;Task:
|
|
Generate 100 <x,y> coordinate pairs such that x and y are integers sampled from the uniform distribution with the condition that <br><math>10 \leq \sqrt{ x^2 + y^2 } \leq 15 </math>. <br>Then display/plot them. The outcome should be a "fuzzy" circle. The actual number of points plotted may be less than 100, given that some pairs may be generated more than once.
|
|
|
|
There are several possible approaches to accomplish this. Here are two possible algorithms.
|
|
|
|
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>.
|
|
|
|
2) Precalculate the set of all possible points (there are 404 of them) and select randomly from this set.
|
|
<br><br>
|
|
|