{"action":"closed","issue":{"url":"https://api.github.com/repos/joshday/OnlineStats.jl/issues/32","repository_url":"https://api.github.com/repos/joshday/OnlineStats.jl","labels_url":"https://api.github.com/repos/joshday/OnlineStats.jl/issues/32/labels{/name}","comments_url":"https://api.github.com/repos/joshday/OnlineStats.jl/issues/32/comments","events_url":"https://api.github.com/repos/joshday/OnlineStats.jl/issues/32/events","html_url":"https://github.com/joshday/OnlineStats.jl/issues/32","id":96622703,"node_id":"MDU6SXNzdWU5NjYyMjcwMw==","number":32,"title":"Reactive framework","user":{"login":"tbreloff","id":933338,"node_id":"MDQ6VXNlcjkzMzMzOA==","avatar_url":"https://avatars1.githubusercontent.com/u/933338?v=4","gravatar_id":"","url":"https://api.github.com/users/tbreloff","html_url":"https://github.com/tbreloff","followers_url":"https://api.github.com/users/tbreloff/followers","following_url":"https://api.github.com/users/tbreloff/following{/other_user}","gists_url":"https://api.github.com/users/tbreloff/gists{/gist_id}","starred_url":"https://api.github.com/users/tbreloff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tbreloff/subscriptions","organizations_url":"https://api.github.com/users/tbreloff/orgs","repos_url":"https://api.github.com/users/tbreloff/repos","events_url":"https://api.github.com/users/tbreloff/events{/privacy}","received_events_url":"https://api.github.com/users/tbreloff/received_events","type":"User","site_admin":false},"labels":[{"id":231650778,"node_id":"MDU6TGFiZWwyMzE2NTA3Nzg=","url":"https://api.github.com/repos/joshday/OnlineStats.jl/labels/brainstorming","name":"brainstorming","color":"eb6420","default":false},{"id":173697696,"node_id":"MDU6TGFiZWwxNzM2OTc2OTY=","url":"https://api.github.com/repos/joshday/OnlineStats.jl/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"state":"closed","locked":false,"assignee":{"login":"tbreloff","id":933338,"node_id":"MDQ6VXNlcjkzMzMzOA==","avatar_url":"https://avatars1.githubusercontent.com/u/933338?v=4","gravatar_id":"","url":"https://api.github.com/users/tbreloff","html_url":"https://github.com/tbreloff","followers_url":"https://api.github.com/users/tbreloff/followers","following_url":"https://api.github.com/users/tbreloff/following{/other_user}","gists_url":"https://api.github.com/users/tbreloff/gists{/gist_id}","starred_url":"https://api.github.com/users/tbreloff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tbreloff/subscriptions","organizations_url":"https://api.github.com/users/tbreloff/orgs","repos_url":"https://api.github.com/users/tbreloff/repos","events_url":"https://api.github.com/users/tbreloff/events{/privacy}","received_events_url":"https://api.github.com/users/tbreloff/received_events","type":"User","site_admin":false},"assignees":[{"login":"tbreloff","id":933338,"node_id":"MDQ6VXNlcjkzMzMzOA==","avatar_url":"https://avatars1.githubusercontent.com/u/933338?v=4","gravatar_id":"","url":"https://api.github.com/users/tbreloff","html_url":"https://github.com/tbreloff","followers_url":"https://api.github.com/users/tbreloff/followers","following_url":"https://api.github.com/users/tbreloff/following{/other_user}","gists_url":"https://api.github.com/users/tbreloff/gists{/gist_id}","starred_url":"https://api.github.com/users/tbreloff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tbreloff/subscriptions","organizations_url":"https://api.github.com/users/tbreloff/orgs","repos_url":"https://api.github.com/users/tbreloff/repos","events_url":"https://api.github.com/users/tbreloff/events{/privacy}","received_events_url":"https://api.github.com/users/tbreloff/received_events","type":"User","site_admin":false}],"milestone":null,"comments":16,"created_at":"2015-07-22T17:31:23Z","updated_at":"2018-09-05T02:32:12Z","closed_at":"2018-09-05T02:32:12Z","author_association":"COLLABORATOR","body":"It would be cool to have some helper functions (or macros?) to set up a Reactive pipeline for `OnlineStat`s.  Here's a toy example of what it may do under the hood.  I set up 2 `OnlineStat`s: a `Diff` and a `Mean`, with the goal of reproducing the equivalent of `mean(diff(x))` when `x` is the full data vector.  `liftdiff` is of type `Reactive.Lift{OnlineStats.Diff{Float64}}`.  Everytime you `push!` to `input`, reactive will take care of calling the function you pass it and place the return value inside the `Lift` object.  Then you can chain the first `Lift` to another one that updates an `OnlineStats.Mean` object.  One call to `push!` on the `Reactive.Input` will trigger the necessary updates and store the return values.\n\n```\njulia> using OnlineStats, Reactive\n\njulia> input = Input(0.0);\n\njulia> d = Diff(); m = Mean();\n\njulia> liftdiff = lift(x -> (update!(d, x); d), input);\n\njulia> liftdiff\nOnline OnlineStats.Diff{Float64}\n *     diff:  0.000000\n\n *     last:  0.000000\n\n *     nobs:  1\n\njulia> typeof(liftdiff)\nReactive.Lift{OnlineStats.Diff{Float64}}\n\njulia> liftmean = lift(d -> (if nobs(d) > 1; update!(m, diff(d)); end; mean(m)), liftdiff);\n\njulia> empty!(d); empty!(m);\n\njulia> println(d); println(m)\nOnlineStats.Diff{Float64}{diff=0.0 last=0.0 nobs=0}\nOnlineStats.Mean{OnlineStats.EqualWeighting}{μ=0.0 nobs=0}\n\njulia> push!(input, 5.0)   # this passes our first data point through the reactive pipeline we set up\n\njulia> println(d); println(m)\nOnlineStats.Diff{Float64}{diff=0.0 last=5.0 nobs=1}\nOnlineStats.Mean{OnlineStats.EqualWeighting}{μ=0.0 nobs=0}\n\njulia> push!(input, 8.0)\n\njulia> println(d); println(m)\nOnlineStats.Diff{Float64}{diff=3.0 last=8.0 nobs=2}\nOnlineStats.Mean{OnlineStats.EqualWeighting}{μ=3.0 nobs=1}\n\njulia> push!(input, 3.0)\n\njulia> println(d); println(m)\nOnlineStats.Diff{Float64}{diff=-5.0 last=3.0 nobs=3}\nOnlineStats.Mean{OnlineStats.EqualWeighting}{μ=-1.0 nobs=2}\n\njulia> @assert value(liftmean) == mean(diff([5.,8.,3.]))  # compare to vector version\n```\n"}}
{"actor":{"display_login":"joshday"}}