Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def volume(a,b,c,c1,n):
- '''Returns the volume of a rectangular Parallelepiped height c1 inside the same surface abc, Monte Carlo method'''
- m = 0 # counts points inside height c1
- v = a*b*c # volume of surface abc
- for i in range(0,n): # n determines number of points generated
- z = random.uniform(0,c) # random height
- if z <= c1: # if inside height c1
- m += 1
- v1 = m/n * v # Ratio between points inside and outside
- return v1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement