-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add RV design spec #266
Add RV design spec #266
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #266 +/- ##
=======================================
Coverage 92.73% 92.73%
=======================================
Files 40 40
Lines 909 909
=======================================
Hits 843 843
Misses 66 66
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
should be represented as constiuent ``RandomVariables`` that are | ||
attributes of ``Var`` (i.e. ``Var.a_rv``, ``Var.b_rv``) and are are | ||
``sample()``-d within ``Var.sample()`` (i.e. ``Var.sample()`` gets an | ||
``a`` value by calling ``self.a_rv.sample()`` and a ``b`` value by | ||
calling ``self.b_rv.sample()``). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this might be too strong. Consider our generic observation processes, which have a mean argument. The mean is almost guaranteed to have been sampled by some other, more complex, RandomVariable that should not itself be wrapped by the observation process:
# Sampling from the latent process
(
post_initialization_latent_infections,
*_,
) = self.latent_infections_rv.sample(
Rt=Rt,
gen_int=gen_int,
I0=I0,
**kwargs,
)
observed_infections, *_ = self.infection_obs_process_rv.sample(
mu=post_initialization_latent_infections[padding:],
obs=data_observed_infections,
**kwargs,
)
This document suggests that post_initialization_latent_infections[padding:]
should be made into a deterministic variable and then passed to the observation process. That seems a bit too much to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand you correctly, @damonbayer, you're saying it's important to allow RandomVariables
to have a mix of:
- parameters defined at construction (which per the document must be
RandomVariable
s, possibly deterministic) - parameters passed directly to the
sample()
call, which may be concrete values, notRandomVariable
s
I am open to this approach, but I would suggest specifying that type (2) parameters (passed when sample()
is called) should always be concrete values and thus represent fixed / "observed" / "data" from the RV's point-of-view. That aligns with the numpyro
pattern of passing obs
arguments to numpyro.sample
calls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've encountered this too in #262. There's no silver bullet here. What if we need a TimeArray
to be passed? I think the call to RV.sample()
should be open to receive whatever (as it does now). Whatever could be a RandomVariable
, a scalar
, an array
, a SampledArray
(aka TimeArray
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now, for instantiation, we probably, suggest using RandomVariable
for anything that resembles a parameter, e.g., scale and loc in your example; but for things like, say, n
(number of elements), we can avoid using RV
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could go stricter though, I do think it's worth thinking about the potential benefits and costs. Will add some thoughts to the document.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could go stricter though, I do think it's worth thinking about the potential benefits and costs. Will add some thoughts to the document.
I agree with Damon & George's earlier sentiments on this but also do think we could go stricter in certain instances, based on what we know about the RVs parameters and potentially also the complexity of the RV / where it lies in the modeling process. Some additional examples might be helpful showcasing the verbosity of the maximally random approach in situations where it feels like "too much"; if these MSR examples end up seeming "not too bad", then I might be more convinced to operate in a maximally random way with MSR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In recent conversations, @dylanhmorris and I seem to have come to an agreement that RandomVariable
s should only have a single stochastic element, as a rule of thumb.
I think is looking great, @dylanhmorris. I think this document will be really useful for future users. As with the timearray stuff, I would be OK to merge this as it is: this is our current understanding and agreement of how parametrization should occur, but it can change in the future. |
Do you need anything from me, @dylanhmorris? |
I don't think the existing writeup is very reflective of our current thinking. A revised write up should be based on the recent developments of dynamic and static distributional random variables (#391) @dylanhmorris Do you want to continue working in this branch or should we close this PR? |
I think it can stay on this branch but I agree it needs a new issue. |
Closing pending further design spec decisions to be made downstream of #407 |
Draft RV design spec added. Draft PR since I haven't configured it to be part of the official docs, etc, as I want comments first.