{"action":"created","issue":{"url":"https://api.github.com/repos/ContinuumIO/dask/issues/297","labels_url":"https://api.github.com/repos/ContinuumIO/dask/issues/297/labels{/name}","comments_url":"https://api.github.com/repos/ContinuumIO/dask/issues/297/comments","events_url":"https://api.github.com/repos/ContinuumIO/dask/issues/297/events","html_url":"https://github.com/ContinuumIO/dask/pull/297","id":87543803,"number":297,"title":"Stable parallel computation of generalized moments","user":{"login":"jcrist","id":2783717,"avatar_url":"https://avatars.githubusercontent.com/u/2783717?v=3","gravatar_id":"","url":"https://api.github.com/users/jcrist","html_url":"https://github.com/jcrist","followers_url":"https://api.github.com/users/jcrist/followers","following_url":"https://api.github.com/users/jcrist/following{/other_user}","gists_url":"https://api.github.com/users/jcrist/gists{/gist_id}","starred_url":"https://api.github.com/users/jcrist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcrist/subscriptions","organizations_url":"https://api.github.com/users/jcrist/orgs","repos_url":"https://api.github.com/users/jcrist/repos","events_url":"https://api.github.com/users/jcrist/events{/privacy}","received_events_url":"https://api.github.com/users/jcrist/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-11T23:48:27Z","updated_at":"2015-06-12T02:26:42Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ContinuumIO/dask/pulls/297","html_url":"https://github.com/ContinuumIO/dask/pull/297","diff_url":"https://github.com/ContinuumIO/dask/pull/297.diff","patch_url":"https://github.com/ContinuumIO/dask/pull/297.patch"},"body":"Adds support for computing generalized moments for a dask array. This results in a more stable computation than that in current master, and allows for computing higher order moments as well.\r\n\r\n```python\r\n>>> import dask.array as da\r\n>>> import numpy as np\r\n\r\n# Poorly conditioned dataset\r\n>>> a = np.array([1., 2., 3.]*100) + 1e8\r\n>>> d = da.from_array(a, chunks=50)\r\n\r\n# numpy answer\r\n>>> a.var()\r\n0.66666666666666663\r\n\r\n# current master\r\n>>>  d.var().compute()\r\n0.0\r\n\r\n# this PR\r\n>>> d.var().compute()\r\n0.66666666655540463\r\n\r\n# Higher order moments\r\n>>> from scipy.stats import moment\r\n>>> da.arange(100, chunks=5).moment(4).compute()\r\n1249583.3625\r\n>>> moment(np.arange(100), 4)\r\n1249583.3625\r\n```\r\n\r\nFixes #78."},"comment":{"url":"https://api.github.com/repos/ContinuumIO/dask/issues/comments/111331700","html_url":"https://github.com/ContinuumIO/dask/pull/297#issuecomment-111331700","issue_url":"https://api.github.com/repos/ContinuumIO/dask/issues/297","id":111331700,"user":{"login":"jcrist","id":2783717,"avatar_url":"https://avatars.githubusercontent.com/u/2783717?v=3","gravatar_id":"","url":"https://api.github.com/users/jcrist","html_url":"https://github.com/jcrist","followers_url":"https://api.github.com/users/jcrist/followers","following_url":"https://api.github.com/users/jcrist/following{/other_user}","gists_url":"https://api.github.com/users/jcrist/gists{/gist_id}","starred_url":"https://api.github.com/users/jcrist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcrist/subscriptions","organizations_url":"https://api.github.com/users/jcrist/orgs","repos_url":"https://api.github.com/users/jcrist/repos","events_url":"https://api.github.com/users/jcrist/events{/privacy}","received_events_url":"https://api.github.com/users/jcrist/received_events","type":"User","site_admin":false},"created_at":"2015-06-12T02:26:42Z","updated_at":"2015-06-12T02:26:42Z","body":"This is a very weird incompatibility bug, I'm not entirely sure what's going on, but this happens.\r\n\r\nPython 2:\r\n```python\r\n>>> np.divide(82.5, 10.0, dtype='f8')\r\n8.25\r\n```\r\nPython 3\r\n```python\r\n>>> np.divide(82.5, 10.0, dtype='f8')\r\n8.1999999999999993\r\n```\r\n\r\nNot sure if this is a numpy bug or not, numpy version 1.9.1 for both."}}