{"action":"created","issue":{"url":"https://api.github.com/repos/pymc-devs/pymc3/issues/781","repository_url":"https://api.github.com/repos/pymc-devs/pymc3","labels_url":"https://api.github.com/repos/pymc-devs/pymc3/issues/781/labels{/name}","comments_url":"https://api.github.com/repos/pymc-devs/pymc3/issues/781/comments","events_url":"https://api.github.com/repos/pymc-devs/pymc3/issues/781/events","html_url":"https://github.com/pymc-devs/pymc3/issues/781","id":92511681,"number":781,"title":"sample() hangs for Multinomial model with more than one observation","user":{"login":"dlinzer","id":1933633,"avatar_url":"https://avatars.githubusercontent.com/u/1933633?v=3","gravatar_id":"","url":"https://api.github.com/users/dlinzer","html_url":"https://github.com/dlinzer","followers_url":"https://api.github.com/users/dlinzer/followers","following_url":"https://api.github.com/users/dlinzer/following{/other_user}","gists_url":"https://api.github.com/users/dlinzer/gists{/gist_id}","starred_url":"https://api.github.com/users/dlinzer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dlinzer/subscriptions","organizations_url":"https://api.github.com/users/dlinzer/orgs","repos_url":"https://api.github.com/users/dlinzer/repos","events_url":"https://api.github.com/users/dlinzer/events{/privacy}","received_events_url":"https://api.github.com/users/dlinzer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2015-07-02T00:00:05Z","updated_at":"2016-09-23T15:34:49Z","closed_at":null,"body":"Hi,\r\n\r\nI'm having a great time with pymc3 so far, but am running into an issue with a basic Dirichlet-Multinomial model.  Here's a setup with fake data:\r\n\r\n```\r\nimport numpy as np\r\nfrom pymc3 import *\r\nsample_size = 1\r\nn = 1000\r\ntrue_probs = [0.2, 0.1, 0.3, 0.4]\r\nk = len(true_probs)\r\ny = np.random.multinomial(n, true_probs, sample_size)\r\n```\r\n\r\nThe model works fine as long as `sample_size = 1`.\r\n\r\n```\r\nmultinom_test = Model()\r\n\r\nwith multinom_test:\r\n    probs = Dirichlet('probs', a = np.array([0.5] * k), shape = k)\r\n    data = Multinomial('data',\r\n                        n = np.reshape(y.sum(1), (sample_size, 1)),\r\n                        p = probs,\r\n                        observed = y)\r\n                        \r\nwith multinom_test:\r\n    trace = sample(5000, Slice())\r\n    \r\ntrace[probs].mean(0)\r\n```\r\n\r\nBut if I set `sample_size = 2` or greater, the `sample()` command hangs. Breaking out of `sample()` in the notebook shows the error:\r\n\r\n```\r\n---------------------------------------------------------------------------\r\nUnboundLocalError                         Traceback (most recent call last)\r\n<ipython-input-12-bcebb63a4efc> in <module>()\r\n      1 with multinom_test:\r\n----> 2     trace = sample(5000, Slice())\r\n\r\n/Users/Drew/PythonEnvs/tracker/lib/python2.7/site-packages/pymc3/sampling.pyc in sample(draws, step, start, trace, chain, njobs, tune, progressbar, model, random_seed)\r\n     86         sample_args = [draws, step, start, trace, chain,\r\n     87                        tune, progressbar, model, random_seed]\r\n---> 88     return sample_func(*sample_args)\r\n     89 \r\n     90 \r\n\r\n/Users/Drew/PythonEnvs/tracker/lib/python2.7/site-packages/pymc3/sampling.pyc in _sample(draws, step, start, trace, chain, tune, progressbar, model, random_seed)\r\n     99                 progress.update(i)\r\n    100     except KeyboardInterrupt:\r\n--> 101         strace.close()\r\n    102     return MultiTrace([strace])\r\n    103 \r\n\r\nUnboundLocalError: local variable 'strace' referenced before assignment\r\n```\r\n\r\nAny thoughts on what's happening here?  Thanks in advance for your help."},"comment":{"url":"https://api.github.com/repos/pymc-devs/pymc3/issues/comments/249225424","html_url":"https://github.com/pymc-devs/pymc3/issues/781#issuecomment-249225424","issue_url":"https://api.github.com/repos/pymc-devs/pymc3/issues/781","id":249225424,"user":{"login":"fonnesbeck","id":81476,"avatar_url":"https://avatars.githubusercontent.com/u/81476?v=3","gravatar_id":"","url":"https://api.github.com/users/fonnesbeck","html_url":"https://github.com/fonnesbeck","followers_url":"https://api.github.com/users/fonnesbeck/followers","following_url":"https://api.github.com/users/fonnesbeck/following{/other_user}","gists_url":"https://api.github.com/users/fonnesbeck/gists{/gist_id}","starred_url":"https://api.github.com/users/fonnesbeck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fonnesbeck/subscriptions","organizations_url":"https://api.github.com/users/fonnesbeck/orgs","repos_url":"https://api.github.com/users/fonnesbeck/repos","events_url":"https://api.github.com/users/fonnesbeck/events{/privacy}","received_events_url":"https://api.github.com/users/fonnesbeck/received_events","type":"User","site_admin":false},"created_at":"2016-09-23T15:34:49Z","updated_at":"2016-09-23T15:34:49Z","body":"We need to fix this before the release. We should not need to loop over the data like this. /cc @twiecki @springcoil "}}
{"actor":{"display_login":"fonnesbeck"}}