{"action":"created","issue":{"url":"https://api.github.com/repos/probcomp/crosscat/issues/62","labels_url":"https://api.github.com/repos/probcomp/crosscat/issues/62/labels{/name}","comments_url":"https://api.github.com/repos/probcomp/crosscat/issues/62/comments","events_url":"https://api.github.com/repos/probcomp/crosscat/issues/62/events","html_url":"https://github.com/probcomp/crosscat/issues/62","id":110827886,"number":62,"title":"Evaluate joint density","user":{"login":"fsaad","id":5721897,"avatar_url":"https://avatars.githubusercontent.com/u/5721897?v=3","gravatar_id":"","url":"https://api.github.com/users/fsaad","html_url":"https://github.com/fsaad","followers_url":"https://api.github.com/users/fsaad/followers","following_url":"https://api.github.com/users/fsaad/following{/other_user}","gists_url":"https://api.github.com/users/fsaad/gists{/gist_id}","starred_url":"https://api.github.com/users/fsaad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fsaad/subscriptions","organizations_url":"https://api.github.com/users/fsaad/orgs","repos_url":"https://api.github.com/users/fsaad/repos","events_url":"https://api.github.com/users/fsaad/events{/privacy}","received_events_url":"https://api.github.com/users/fsaad/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"fsaad","id":5721897,"avatar_url":"https://avatars.githubusercontent.com/u/5721897?v=3","gravatar_id":"","url":"https://api.github.com/users/fsaad","html_url":"https://github.com/fsaad","followers_url":"https://api.github.com/users/fsaad/followers","following_url":"https://api.github.com/users/fsaad/following{/other_user}","gists_url":"https://api.github.com/users/fsaad/gists{/gist_id}","starred_url":"https://api.github.com/users/fsaad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fsaad/subscriptions","organizations_url":"https://api.github.com/users/fsaad/orgs","repos_url":"https://api.github.com/users/fsaad/repos","events_url":"https://api.github.com/users/fsaad/events{/privacy}","received_events_url":"https://api.github.com/users/fsaad/received_events","type":"User","site_admin":false},"milestone":null,"comments":2,"created_at":"2015-10-11T01:44:00Z","updated_at":"2015-10-13T15:08:36Z","closed_at":null,"body":"There is currently no way to evaluate `P(X=x,Y=y,Z=z)` under the joint density of `(X,Y,Z)`. \r\n\r\nWe need to expose joint density evaluation in the interface. My first idea was to change `simple_predictive_probability` which takes a list of disjoint univariate queries and interpret the input instead as joint. Currently we have:\r\n\r\n```python\r\n    def simple_predictive_probability(self, M_c, X_L, X_D, Y, Q):\r\n        :param Q: A list of values to sample.  Each value is doublet of (r, d, v):\r\n                  r is the row index, d is the column index, v is the value\r\n        :type Q: list of lists\r\n        :returns: list of floats -- probabilities of the values specified by Q\r\n```\r\n\r\nwhich can only evaluate `P(col_d = v | row = r)`, or the univariate marginal distribution for `col_d`. If you input multiple columns, than multiple univariate densities are returned. We need `Q` to take a list of lists of tuples.\r\n\r\nHowever it appears there are several tests that invoke `simple_predictive_probability` which such a change might break.\r\n\r\nThe second best option is to create `joint_predictive_probability` function in the interface (and invoke this one through bayeslite)."},"comment":{"url":"https://api.github.com/repos/probcomp/crosscat/issues/comments/147744162","html_url":"https://github.com/probcomp/crosscat/issues/62#issuecomment-147744162","issue_url":"https://api.github.com/repos/probcomp/crosscat/issues/62","id":147744162,"user":{"login":"axch","id":233710,"avatar_url":"https://avatars.githubusercontent.com/u/233710?v=3","gravatar_id":"","url":"https://api.github.com/users/axch","html_url":"https://github.com/axch","followers_url":"https://api.github.com/users/axch/followers","following_url":"https://api.github.com/users/axch/following{/other_user}","gists_url":"https://api.github.com/users/axch/gists{/gist_id}","starred_url":"https://api.github.com/users/axch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/axch/subscriptions","organizations_url":"https://api.github.com/users/axch/orgs","repos_url":"https://api.github.com/users/axch/repos","events_url":"https://api.github.com/users/axch/events{/privacy}","received_events_url":"https://api.github.com/users/axch/received_events","type":"User","site_admin":false},"created_at":"2015-10-13T15:08:36Z","updated_at":"2015-10-13T15:08:36Z","body":"Just looked at `simple_predictive_probability` in crosscat version 0.1.35.  A few facts appear to hold, which are jointly rather confusing:\r\n- As @fsaad noted, the interface to `simple_predictive_probability` itself maps over the query argument.\r\n- I can't see any performance advantage to mapping over the query argument: all the work is inside the loop anyway, and nothing is cached except by the global cache on `create_cluster_model_from_X_L` that I introduced recently.\r\n- `simple_predictive_probability_multistate`, which is what Bayeslite's crosscat metamodel calls, relies on the answer being a scalar (specifically, a numpy array of size 1, which can be converted to a floating point scalar by `float` -- unlike numpy arrays of other sizes).\r\n\r\nIn light of this, and @vkmvkmvkmvkm 's comment above, I suggest redefining `simple_predictive_probability` to return the joint probability of all the query cells (as a number, not a numpy array) and adjusting the tests to assume that (most of them seem to be crash-only tests anyway?)\r\n\r\nI also explicitly suggest dropping the automatic mapping idea from this interface: if the client wants multiple independent queries, let them call the function many times."}}