Apr-08-2018, 02:29 AM
I had this on my programming exam last week. I still don't get desired outcome.
How would you solve it?
1 Randomly generate 10^4 points (x_i, y_i) where x_i and y_i are uniformly distributed on interval [-1,1].
2 Figure out: How many of these points are inside uniform circle M and calculate ratio R=4M/N.
3 In created script.py repeat this for different seeds (of a generator).
4 Export your file into file.dat in which there has to be two columns- seed and R.
5 In the same script show (for one random seed) earlier generated points: Points inside uniform circle are coloured red and outside ones are coloured blue.
6 Nicely arrange the result with added legend.
7 Export the graph into file graph.pdf.
Hint: use Matplotlib for points 5, and 6.

How would you solve it?
1 Randomly generate 10^4 points (x_i, y_i) where x_i and y_i are uniformly distributed on interval [-1,1].
2 Figure out: How many of these points are inside uniform circle M and calculate ratio R=4M/N.
3 In created script.py repeat this for different seeds (of a generator).
4 Export your file into file.dat in which there has to be two columns- seed and R.
5 In the same script show (for one random seed) earlier generated points: Points inside uniform circle are coloured red and outside ones are coloured blue.
6 Nicely arrange the result with added legend.
7 Export the graph into file graph.pdf.
Hint: use Matplotlib for points 5, and 6.