Conversation
Jenkins Console Log Machine informationNo LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.3 LTS Release: 20.04 Codename: focalCPU: G++: Clang: |
|
Rtools & ARM64 CI / rev tests (windows-11-arm) (pull_request) Seems a test on ode fails, but this might be unrelated to this PR? My mac can pass the rev tests. |
|
@lingium it passed on re-run, so I think it was just random noise |
SteveBronder
left a comment
There was a problem hiding this comment.
Two minor comments but imo looks good!
| scalar_seq_view<T_w> w_vec(w); | ||
| size_t size_w = stan::math::size(w); | ||
|
|
||
| VectorBuilder<true, int, T_alpha> output(size_w); | ||
| for (size_t n = 0; n < size_w; ++n) { | ||
| double p = stan::math::exp(-w_vec.val(n)); | ||
| double odds_ratio_p | ||
| = stan::math::exp(stan::math::log(p) - stan::math::log1m(p)); | ||
| output[n] = neg_binomial_rng(1.0, odds_ratio_p, rng) + 1; | ||
| } | ||
|
|
||
| return output.data(); |
There was a problem hiding this comment.
Since you use neg_binomial_rng I think we can use the vectorized version of everything here
| scalar_seq_view<T_w> w_vec(w); | |
| size_t size_w = stan::math::size(w); | |
| VectorBuilder<true, int, T_alpha> output(size_w); | |
| for (size_t n = 0; n < size_w; ++n) { | |
| double p = stan::math::exp(-w_vec.val(n)); | |
| double odds_ratio_p | |
| = stan::math::exp(stan::math::log(p) - stan::math::log1m(p)); | |
| output[n] = neg_binomial_rng(1.0, odds_ratio_p, rng) + 1; | |
| } | |
| return output.data(); | |
| auto p = stan::math::exp(-w); | |
| auto odds_ratio_p = stan::math::exp(stan::math::log(p) - stan::math::log1m(p)); | |
| return neg_binomial_rng(1.0, odds_ratio_p, rng) + 1; |
There was a problem hiding this comment.
Seems neg_binomial_rng(...) + 1; cannot pass compile, let's keep the loop version?
Jenkins Console Log Machine informationNo LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.3 LTS Release: 20.04 Codename: focalCPU: G++: Clang: |
Summary
With this PR the rng of Yule-Simon distribution are added.
See issue #3239
For$$Y\sim \text{Yule-Simon}(\alpha)$$ :
It has a Beta–Geometric mixture. To sample form$$Y$$ , we do:
Stan does not have Geometric yet so we use
neg_binomial_rng(1.0, odds_ratio_p).Tests
Test is written follow the guide.
Side Effects
No.
Release notes
yule_simon_rngis available if merged.Checklist
Copyright holder: Zhi Ling
The copyright holder is typically you or your assignee, such as a university or company. By submitting this pull request, the copyright holder is agreeing to the license the submitted work under the following licenses:
- Code: BSD 3-clause (https://opensource.org/licenses/BSD-3-Clause)
- Documentation: CC-BY 4.0 (https://creativecommons.org/licenses/by/4.0/)
the basic tests are passing
./runTests.py test/unit)make test-headers)make test-math-dependencies)make doxygen)make cpplint)the code is written in idiomatic C++ and changes are documented in the doxygen
the new changes are tested