title: Improving a Monte Carlo code to find the volume of sphere in Higher dimension. (PYTHON)
body: <p>Considering Gaussian shape  we can find the  volume of n dimensional volume of a sphere. My intention is to find the  volume using Monte Carlo method. </p>
  
  <p>Using the gaussian integral I have found the formula </p>
  
  <p><a href="https://i.stack.imgur.com/gpiyU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gpiyU.png" alt="enter image description here"></a></p>
  
  <p>What I understand that the ratio of the points inside the n-dimensional sphere to the total number of points will then be roughly the same as the ratio of the volume of the ball to that of the cube. I mean the mass density would never change , whatever dimension I use. </p>
  
  <p>Therefore  I assume I should follow the same technique what  I used to find the value of pi using Monte Carlo method. </p>
  
  <p>I don't understand how to  follow the  code  which I evaluated to find the value of pi.</p>
  
  <pre><code>import random
  
  TIMES_TO_REPEAT = 10**5
  LENGTH = 10**5
  
  def in_circle(x, y):
      return x**2 + y**2 &lt; LENGTH**2
  
  inside_count = 0
  for _ in range(TIMES_TO_REPEAT):
      point = random.randint(0,LENGTH), random.randint(0,LENGTH)
      if in_circle(*point):
          inside_count += 1
  
  pi = (inside_count / TIMES_TO_REPEAT) * 4
  
  print(pi) 
  </code></pre>
  
  <p>How can I apply the inequality condition in the code I have mentioned so the mass density would be same and I can find the value of volume in Higher dimension.?</p>