title: How can I integrate a custom step function in python accurately (scipy.integrate.quad returning very high error)?
body: <p>I have a custom step function that, when plotted, is like this:<a href="https://i.stack.imgur.com/i3oVC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/i3oVC.png" alt="enter image description here"></a></p>
  
  <p>I have modified the datetimes to float values using .timestamp(), and have used scipy.integrate.quad to integrate this. However, the absolute error I get as an output is incredibly high - over the full range of my data (approximately 30x the plot, but in the similar pattern) - I get a integral value of 776197710.7495924 but an error value of 525307969.5046983 which is the same magnitude. When I choose not to use the step function and instead smoothly interpolate over the points using scipy.interp1d and then integrate that function, I get similar figures.</p>
  
  <p>How can I integrate this with less error? </p>
  
  <p>EDIT: I am fully aware of how to just sum the rectangles created by the step function, but I want to understand how I might do this with scipy. Thanks!</p>