-
Notifications
You must be signed in to change notification settings - Fork 1
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
Rewrite functions for sampling from discrete truncated distributions #77
Comments
This is the same as #72, isn't it? Also, is there any impediments for implementing this for continuous distributions as well? |
Perhaps... not sure... Seems to me, that there is a coding issue (only calling rtrunc vs sampleFromUntruncated) and a content/solution issue: How do we actually do it?
/R
Fra: Waldir Leoncio ***@***.***>
Svar til: ocbe-uio/TruncExpFam ***@***.***>
Dato: mandag 21. februar 2022 kl. 11:11
Til: ocbe-uio/TruncExpFam ***@***.***>
Kopi: Rene Holst ***@***.***>, Author ***@***.***>
Emne: Re: [ocbe-uio/TruncExpFam] Rewrite functions for sampling from discrete truncated distributions (Issue #77)
This is the same as #72<#72>, isn't it? Also, is there any impediments for implementing this for continuous distributions as well?
—
Reply to this email directly, view it on GitHub<#77 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AFPRUPWKSFLENKXSPDR3Z53U4IFTRANCNFSM5O6C6QLA>.
Triage notifications on the go with GitHub Mobile for iOS<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
If I understood correctly, the Binomial implementation is here: Lines 15 to 31 in 087ad1b
The f(x) / [F(b) - F(a)] part is clearly defined on L28. f(x) (i.e., So a DRY solution might involve the following steps:
One thing that worries me about this approach is that this will probably make the output of |
An alternative to phasing out the old algotirhm is to have |
Function is similar to `rescaledDensities()`, though the latter is supposed to serve #77 (i.e., discrete distributions). Some eventual merging may be in order.
Approach pursued so far
Sample from original (not truncated) distribution, followed by a truncation. In-efficient approach: Samples a surplus of unnecessary elements and difficult to predict the sample size required to achieve the target sample size.
Solution
Sample directly from the truncated distribution:
Use$a, ..., b$ with weights $f_T(a, ..., b; \theta)$
sample()
to sample fromImplemented for binomial. See code there. Needs to be implemented for other discrete distributions: Poisson, Neg. bin. others?
OBS: weights$f_T(x; \theta)$ are already implemented as
dtrunc.XXXX()
functionsThe text was updated successfully, but these errors were encountered: