title: Python function to find the numeric volume integral?
body: <h1>Goal</h1>
  <p>I would like to compute the 3D volume integral of a numeric scalar field.</p>
  <h1>Code</h1>
  <p>For this post, I will use an example of which the integral can be exactly computed. I have therefore chosen the following function:</p>
  <p><a href="https://i.stack.imgur.com/WfJ0P.png" rel="noreferrer"><img src="https://i.stack.imgur.com/WfJ0P.png" alt="Integral function" /></a></p>
  <p>In Python, I define the function, and a set of points in 3D, and then generate the discrete values at these points:</p>
  <pre><code>import numpy as np
  
  
  # Make data.
  def function(x, y, z):
      return x**y**z
  
  N = 5
  grid = np.meshgrid(
      np.linspace(0, 1, N),
      np.linspace(0, 1, N),
      np.linspace(0, 1, N)
  )
  
  points = np.vstack(list(map(np.ravel, grid))).T
  
  x = points[:, 0]
  y = points[:, 1]
  z = points[:, 2]
  
  values = [function(points[i, 0], points[i, 1], points[i, 2])
            for i in range(len(points))]
  </code></pre>
  <h1>Question</h1>
  <p>How can I find the integral, if I don't know the underlying function, i.e. if I only have the coordinates (<code>x, y, z</code>) and the <code>values</code>?</p>