{"action":"created","issue":{"url":"https://api.github.com/repos/scipy/scipy/issues/4264","labels_url":"https://api.github.com/repos/scipy/scipy/issues/4264/labels{/name}","comments_url":"https://api.github.com/repos/scipy/scipy/issues/4264/comments","events_url":"https://api.github.com/repos/scipy/scipy/issues/4264/events","html_url":"https://github.com/scipy/scipy/issues/4264","id":51917214,"number":4264,"title":"Feature or bug? : scipy.integrate.simps : result for integration of pulse is position dependent","user":{"login":"xcartoixa","id":10184116,"avatar_url":"https://avatars.githubusercontent.com/u/10184116?v=3","gravatar_id":"","url":"https://api.github.com/users/xcartoixa","html_url":"https://github.com/xcartoixa","followers_url":"https://api.github.com/users/xcartoixa/followers","following_url":"https://api.github.com/users/xcartoixa/following{/other_user}","gists_url":"https://api.github.com/users/xcartoixa/gists{/gist_id}","starred_url":"https://api.github.com/users/xcartoixa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xcartoixa/subscriptions","organizations_url":"https://api.github.com/users/xcartoixa/orgs","repos_url":"https://api.github.com/users/xcartoixa/repos","events_url":"https://api.github.com/users/xcartoixa/events{/privacy}","received_events_url":"https://api.github.com/users/xcartoixa/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/scipy/scipy/labels/enhancement","name":"enhancement","color":"bfe5bf"},{"url":"https://api.github.com/repos/scipy/scipy/labels/scipy.integrate","name":"scipy.integrate","color":"207de5"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2014-12-14T11:47:05Z","updated_at":"2015-01-02T21:50:01Z","closed_at":null,"body":" Hi, I am a newbie in python, using\r\n\r\n```\r\nPython 2.7.5 (default, Feb 19 2014, 13:47:28) \r\n[GCC 4.8.2 20131212 (Red Hat 4.8.2-7)] on linux2\r\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\r\n>>> import scipy\r\n>>> print scipy.__version__\r\n0.12.1\r\n>>> print scipy.__numpy_version__\r\n1.8.2\r\n```\r\n\r\nI am trying to perform an integration using Simpson's method, and I am running into issues that I have been able to track down to the following behaviour:\r\n\r\n```\r\n>>> from scipy.integrate import simps\r\n>>> simps([0,0,0,0,0,1,0,0,0,0,0], None, 1, -1, 'avg')\r\n1.3333333333333333\r\n>>> simps([0,0,0,0,0,1,0,0,0,0,0], None, 1, -1, 'first')\r\n1.3333333333333333\r\n>>> simps([0,0,0,0,0,1,0,0,0,0,0], None, 1, -1, 'last')\r\n1.3333333333333333\r\n>>> simps([0,0,0,0,1,0,0,0,0,0,0], None, 1, -1, 'avg')\r\n0.66666666666666663\r\n>>> simps([0,0,0,0,1,0,0,0,0,0,0], None, 1, -1, 'first')\r\n0.66666666666666663\r\n>>> simps([0,0,0,0,1,0,0,0,0,0,0], None, 1, -1, 'last')\r\n0.66666666666666663\r\n```\r\n\r\nwhere the result of the integration depends on where my 1 is (taking more samples to resolve the peak is not an option, since I am trying to gracefully handle an impulse function). Reading http://en.wikipedia.org/wiki/Simpson%27s_rule#Composite_Simpson.27s_rule , this seems to come from whether the sample has a relative weight of 2 or 4 in the implementation of the formula.\r\n\r\nNote that if the list has 10 members instead of 11, I get even more varying results\r\n```\r\n>>> simps([0,0,0,0,1,0,0,0,0,0], None, 1, -1, 'avg')\r\n1.0\r\n>>> simps([0,0,0,0,1,0,0,0,0,0], None, 1, -1, 'first')\r\n0.66666666666666663\r\n>>> simps([0,0,0,0,1,0,0,0,0,0], None, 1, -1, 'last')\r\n1.3333333333333333\r\n>>> simps([0,0,0,0,0,1,0,0,0,0], None, 1, -1, 'avg')\r\n1.0\r\n>>> simps([0,0,0,0,0,1,0,0,0,0], None, 1, -1, 'first')\r\n1.3333333333333333\r\n>>> simps([0,0,0,0,0,1,0,0,0,0], None, 1, -1, 'last')\r\n0.66666666666666663\r\n```\r\nWould the developers consider implementing the formula in http://en.wikipedia.org/wiki/Simpson%27s_rule#Alternative_extended_Simpson.27s_rule instead, which seems to be much less sensitive to small shifts of sharp peaks in the integrand?\r\n\r\nThanks\r\n"},"comment":{"url":"https://api.github.com/repos/scipy/scipy/issues/comments/68565712","html_url":"https://github.com/scipy/scipy/issues/4264#issuecomment-68565712","issue_url":"https://api.github.com/repos/scipy/scipy/issues/4264","id":68565712,"user":{"login":"bewithaman","id":10278482,"avatar_url":"https://avatars.githubusercontent.com/u/10278482?v=3","gravatar_id":"","url":"https://api.github.com/users/bewithaman","html_url":"https://github.com/bewithaman","followers_url":"https://api.github.com/users/bewithaman/followers","following_url":"https://api.github.com/users/bewithaman/following{/other_user}","gists_url":"https://api.github.com/users/bewithaman/gists{/gist_id}","starred_url":"https://api.github.com/users/bewithaman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bewithaman/subscriptions","organizations_url":"https://api.github.com/users/bewithaman/orgs","repos_url":"https://api.github.com/users/bewithaman/repos","events_url":"https://api.github.com/users/bewithaman/events{/privacy}","received_events_url":"https://api.github.com/users/bewithaman/received_events","type":"User","site_admin":false},"created_at":"2015-01-02T21:50:01Z","updated_at":"2015-01-02T21:50:01Z","body":"@rgommers  I am working on this.\r\nBut one thing I didn't understood is  that what  _basic_simps function does when samples with unequal difference are given. Documentations says that it uses Newton- Coates formulae but I didn't found anything related on google. Can you tell me any link or anything else which could help me understand line https://github.com/scipy/scipy/blob/f19d2ea55dc5537e754e3768a4c6727b28e92eaa/scipy/integrate/quadrature.py#L321 "}}