samedi 7 avril 2018

Complex Math Program solved by using Python and Matplotlib?

I just recently started learning Python. I wrote some simple programs, but the following problem seems like climbing up Mount Everest. I'm taking exercises from a textbook written for math students (the problems are harder to crack), but unfortunately there are no solutions or guidelines. Here it is:

  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.

The only hint here is to use Matplotlib for points 5, and 6.

Any help here appreciated.




Aucun commentaire:

Enregistrer un commentaire