Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sum of random variable and deterministic value? #251

Closed
slwu89 opened this issue Feb 28, 2023 · 2 comments
Closed

sum of random variable and deterministic value? #251

slwu89 opened this issue Feb 28, 2023 · 2 comments

Comments

@slwu89
Copy link
Contributor

slwu89 commented Feb 28, 2023

Hi, I'm curious if its possible to do something like the following (not valid code):

10 + Binomial(10, 0.5)

to get a measure assigning probability to the values between 10 and 20. I naively did Binomial(10, 0.5) + Dirac(10) but that generates a mixture/superposition.

Incidentally, the interest in this arose from using Chain to implement a time discretization of a competing counting processes representation of an SIR model. It would be nice if the state of the chain could be defined on the 2 increasing integers counting the total number of times each event has fired, right now it's simply defined on the number of events occurring each time step. The relevant code is here: https://github.com/epirecipes/sir-julia/blob/master/markdown/markov_measure/markov_measure.md#transitions (i.e. I wish I could write productmeasure([x[1] + si_rv, x[2] + ir_rv]) at the last line.

@slwu89
Copy link
Contributor Author

slwu89 commented Mar 2, 2023

Ah, it's in the AffineTransform part of the API. I missed this when I was looking through the docs, closing!

@slwu89 slwu89 closed this as completed Mar 2, 2023
@slwu89
Copy link
Contributor Author

slwu89 commented Mar 2, 2023

If anyone else needs this in the future, it is done as something like:

f = AffineTransform((μ=10,))
rand(pushfwd(f, Binomial(10,0.5)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant