Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #3.14
- import random
- from random import randint
- import matplotlib
- import matplotlib.pyplot as plt
- N=100000
- a,b=[],[]
- n=0
- for i in range (N):
- x=random.uniform(0,1)
- y=random.uniform(0,1)
- if (x+y<1) and (x*y<2/9):
- a.append(x)
- b.append(y)
- n+=1
- print(n/N)
- plt.plot(a,b, linestyle="",marker="o")
- plt.title('PLOT')
- plt.show()
Add Comment
Please, Sign In to add comment