{"action":"created","issue":{"url":"https://api.github.com/repos/econtoolkit/Expectations.jl/issues/6","repository_url":"https://api.github.com/repos/econtoolkit/Expectations.jl","labels_url":"https://api.github.com/repos/econtoolkit/Expectations.jl/issues/6/labels{/name}","comments_url":"https://api.github.com/repos/econtoolkit/Expectations.jl/issues/6/comments","events_url":"https://api.github.com/repos/econtoolkit/Expectations.jl/issues/6/events","html_url":"https://github.com/econtoolkit/Expectations.jl/issues/6","id":340727781,"node_id":"MDU6SXNzdWUzNDA3Mjc3ODE=","number":6,"title":"Expectation with pre-existing grid and the trapezoidal rule","user":{"login":"jlperla","id":13106721,"node_id":"MDQ6VXNlcjEzMTA2NzIx","avatar_url":"https://avatars2.githubusercontent.com/u/13106721?v=4","gravatar_id":"","url":"https://api.github.com/users/jlperla","html_url":"https://github.com/jlperla","followers_url":"https://api.github.com/users/jlperla/followers","following_url":"https://api.github.com/users/jlperla/following{/other_user}","gists_url":"https://api.github.com/users/jlperla/gists{/gist_id}","starred_url":"https://api.github.com/users/jlperla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jlperla/subscriptions","organizations_url":"https://api.github.com/users/jlperla/orgs","repos_url":"https://api.github.com/users/jlperla/repos","events_url":"https://api.github.com/users/jlperla/events{/privacy}","received_events_url":"https://api.github.com/users/jlperla/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"ArnavSood","id":5009477,"node_id":"MDQ6VXNlcjUwMDk0Nzc=","avatar_url":"https://avatars1.githubusercontent.com/u/5009477?v=4","gravatar_id":"","url":"https://api.github.com/users/ArnavSood","html_url":"https://github.com/ArnavSood","followers_url":"https://api.github.com/users/ArnavSood/followers","following_url":"https://api.github.com/users/ArnavSood/following{/other_user}","gists_url":"https://api.github.com/users/ArnavSood/gists{/gist_id}","starred_url":"https://api.github.com/users/ArnavSood/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ArnavSood/subscriptions","organizations_url":"https://api.github.com/users/ArnavSood/orgs","repos_url":"https://api.github.com/users/ArnavSood/repos","events_url":"https://api.github.com/users/ArnavSood/events{/privacy}","received_events_url":"https://api.github.com/users/ArnavSood/received_events","type":"User","site_admin":false},"assignees":[{"login":"ArnavSood","id":5009477,"node_id":"MDQ6VXNlcjUwMDk0Nzc=","avatar_url":"https://avatars1.githubusercontent.com/u/5009477?v=4","gravatar_id":"","url":"https://api.github.com/users/ArnavSood","html_url":"https://github.com/ArnavSood","followers_url":"https://api.github.com/users/ArnavSood/followers","following_url":"https://api.github.com/users/ArnavSood/following{/other_user}","gists_url":"https://api.github.com/users/ArnavSood/gists{/gist_id}","starred_url":"https://api.github.com/users/ArnavSood/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ArnavSood/subscriptions","organizations_url":"https://api.github.com/users/ArnavSood/orgs","repos_url":"https://api.github.com/users/ArnavSood/repos","events_url":"https://api.github.com/users/ArnavSood/events{/privacy}","received_events_url":"https://api.github.com/users/ArnavSood/received_events","type":"User","site_admin":false}],"milestone":null,"comments":2,"created_at":"2018-07-12T17:21:58Z","updated_at":"2018-07-17T21:54:24Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"Something that comes up a lot in macro is the need to calculate expectations where a (often irregular) grid is predefined.  For example, something like\r\n```julia\r\nusing Distributions\r\nx_max = 2.0\r\nd = Truncated(Exponential(0.1), 0.0, x_max) #truncated exponential\r\nx = [linspace(0.0, 1.0, 10); linspace(1.01, x_max, 20) #match support\r\nE = expectation(d, x, :trapezoidal)\r\n\r\n#Calculate expectation E(x^2)\r\nh(x) = x^2\r\nval = E(h)\r\n\r\n#Or using the weights yourself.\r\nval = dot(weights(E), h.(x))\r\n```\r\n\r\nNote that there could be dispatching in `expectation(d, x, :trapezoidal)` depending on if `x` is an `AbstractVector` vs. a `StepRangeLen` or `UnitRange`.  In the case of the latter, it could provide the (simpler) regular grid trapezoidal rule.  Which should probably be a lazy iterator rather than an actual vector."},"comment":{"url":"https://api.github.com/repos/econtoolkit/Expectations.jl/issues/comments/405740845","html_url":"https://github.com/econtoolkit/Expectations.jl/issues/6#issuecomment-405740845","issue_url":"https://api.github.com/repos/econtoolkit/Expectations.jl/issues/6","id":405740845,"node_id":"MDEyOklzc3VlQ29tbWVudDQwNTc0MDg0NQ==","user":{"login":"Nosferican","id":2529329,"node_id":"MDQ6VXNlcjI1MjkzMjk=","avatar_url":"https://avatars0.githubusercontent.com/u/2529329?v=4","gravatar_id":"","url":"https://api.github.com/users/Nosferican","html_url":"https://github.com/Nosferican","followers_url":"https://api.github.com/users/Nosferican/followers","following_url":"https://api.github.com/users/Nosferican/following{/other_user}","gists_url":"https://api.github.com/users/Nosferican/gists{/gist_id}","starred_url":"https://api.github.com/users/Nosferican/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Nosferican/subscriptions","organizations_url":"https://api.github.com/users/Nosferican/orgs","repos_url":"https://api.github.com/users/Nosferican/repos","events_url":"https://api.github.com/users/Nosferican/events{/privacy}","received_events_url":"https://api.github.com/users/Nosferican/received_events","type":"User","site_admin":false},"created_at":"2018-07-17T21:54:24Z","updated_at":"2018-07-17T21:54:24Z","author_association":"COLLABORATOR","body":"`f_vec = pdf.(Ref(dist), nodes)` should work in Julia 0.7 without deprecations. Check without the `Ref` in case it is not needed."}}
{"actor":{"display_login":"Nosferican"}}