Generate a process that would generate random numbers between –1 and 1 for x and y positions of 10000 points and count how many points fall with the circle, then determine an estimated version of π. (see below to generate floating point random numbers. this generation is not needed to describe the process, but to implement the process)

Respuesta :

#!/usr/bin/env python

import random
import math
count_inside = 0
     for count in range(0, 10000): d = math.hypot(random.random(), random.random())
    if d < 1: count_inside += 1
count += 1
print 4.0 * count_inside / count
ACCESS MORE
EDU ACCESS
Universidad de Mexico