-
Notifications
You must be signed in to change notification settings - Fork 70
Add GrassiaIIGeometric Distribution #528
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
269dd75
b264161
d734c68
71bd632
48e93f3
93c4a60
d2e72b5
8685005
026f182
d12dd0b
bcd9cac
78be107
f3ae359
8a30459
7c7afc8
fa9c1ec
b957333
d0c1d98
264c55e
05e7c55
0fa3390
5baa6f7
a715ec7
f3c0f29
a232e4c
ffc059f
1d41eb7
47ad523
5b77263
eb7222f
b34e3d8
9803321
5ff6853
63a0b10
932a046
b78a5c4
ab45a9c
0d1dcea
434e5a5
86085ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -425,10 +425,12 @@ def rng_fn(cls, rng, r, alpha, time_covariate_vector, size): | |
# Calculate exp(time_covariate_vector) for all samples | ||
exp_time_covar = np.exp( | ||
time_covariate_vector | ||
).mean() # must average over time for correct broadcasting | ||
).mean() # Approximation required to return a t-scalar from a covariate vector | ||
lam_covar = lam * exp_time_covar | ||
|
||
samples = np.ceil(rng.exponential(size=size) / lam_covar) | ||
# Take uniform draws from the inverse CDF | ||
u = rng.uniform(size=size) | ||
samples = np.ceil(np.log(1 - u) / (-lam_covar)) | ||
|
||
return samples | ||
|
||
|
@@ -581,5 +583,5 @@ def C_t(t: pt.TensorVariable, time_covariate_vector: pt.TensorVariable) -> pt.Te | |
# If t_idx exceeds length of time_covariate_vector, use last value | ||
max_idx = pt.shape(time_covariate_vector)[0] - 1 | ||
safe_idx = pt.minimum(t_idx, max_idx) | ||
covariate_value = time_covariate_vector[safe_idx] | ||
return t * pt.exp(covariate_value) | ||
covariate_value = time_covariate_vector[..., safe_idx] | ||
return pt.exp(covariate_value).sum() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By "batched" do you mean ragged arrays? What is required to handle those? This is expected for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ricardoV94 how is slicing handled for arrays in |
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.
Are you sure about
log(1 - u)
? When I was writing in paper it seemed like it should just belog(u)
, or alternativelyexponential
and the-
inlam_covar
can be skippedThere 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.
Rather new to deriving inverse CDFs (and this particular derivation I did at 2am last night), but here's my general understanding:
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.
t is a vector so I don't think that makes sense. I'm not sure you can even invert the CDF of a multivariate distribution, because it won't be 1-1 in general.
Uh oh!
There was an error while loading. Please reload this page.
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.
t == len(C(t))
. I'm not happy with the approximation, but it was the only way I could think of to use the inverse CDF.The only alternative is
t
geometric draws for each sample covariate vector. To provide time context, the vector has to be aggregated in some way, be it sum, mean, or product. Might just have to start experimenting with PPCs in a notebook to see which agg option seems most viableThere 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.
From your description of the situation that sounds the most reasonable