a guest Oct 16th, 2018 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def volume(a,b,c,c1,n):
  2.     '''Returns the volume of a rectangular Parallelepiped height c1 inside the same surface abc, Monte Carlo method'''
  3.     m = 0 # counts points inside height c1
  4.     v = a*b*c # volume of surface abc
  5.     for i in range(0,n): # n determines number of points generated
  6.         z = random.uniform(0,c) # random height
  7.         if z <= c1: # if inside height c1
  8.             m += 1
  9.     v1 = m/n * v # Ratio between points inside and outside
  10.     return v1
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand