Comments (8)
Would also be good if the vectorized RNGs would accept vector arguments like dnorm
in R and broadcast the smaller ones. We already have the VectorView
framework in place for this. With vector arguments, we don't need a redundant numerical argument, so there are really two extensions:
- vector argument(s)
- number of repetition arguments with scalars
The second is much easier as it's basically just a bunch of loops.
from math.
For example, for the normal distribution, we would want to support these three signatures in Stan:
vector normal_rng(vector mu, real sigma);
vector normal_rng(real mu, vector sigma);
vector normal_rng(vector mu, vector sigma);
with broadcasting of the scalar to a vector. When two vectors are present, they must be the same size.
The existing implementations can be generalized using the expression template scalar_seq_view
in the same way as the log probability density functions. That lets you view either a scalar or sequence as a sequence and write a single implementation.
A second kind of vectorization that would be convenient would be to have:
vector normal_rng(int N, real mu, real sigma);
to generate N draws with a single pair of parameters.
R just uses a single function that combines the two patterns, requiring an N, and a scalar or vector location and a scalar or vector scale parameter.
from math.
I opened a pull req. to get started on this: #573 . Hopefully I didn't go too far off the beaten path.
from math.
I didn't realize you were working on this, as I just suggested to someone else that they work on it. I'll try to fish out your email and respond that way as I don't know the other person's GitHub handle, so I can't call it out here.
from math.
I will take a look when I get a chance, but I'm getting bombarded by people wanting me to look over code these days.
from math.
Haha, I wasn't working on it till yesterday -- it's no problem if the pull I made gets replaced. I was just getting annoyed at having to write for loops for things that in the model were nicely vectorized so I figured I'd give it a go.
from math.
@bbbales2 We can close this one right?
from math.
I think so.
from math.
Related Issues (20)
- [Feature] Add a bracketing rootfinder HOT 6
- Jenkins OpenCL tests failing on jenkins2 but not jenkins1 HOT 3
- Testing: decrease impact of distribution tests on CI hardware HOT 5
- SDE distribution
- csr_to_dense_matrix fails when first row is all zeros HOT 1
- Compilation error when including Eigen and Stan together HOT 5
- normal_lcdf and normal_lccdf give infinite gradients for infinite inputs. HOT 3
- [Admin] `licenses/` directory out of date
- [BUG] `eigenvalues_sym` returns a matrix instead of a vector
- eigenvalues_sym return type breaks RcppEigen compat
- Failure to build TBB when using GCC 13 HOT 6
- Compiling with O1 leads to failing chains with compound declaration and assignment with range indices HOT 7
- boost 1.82 upgrade HOT 8
- Distributions - Replace separate `propto` template with default argument?
- feature request: configurable constraint tolerance
- Hessian-vector product with central finite differences
- tbb/area.cpp triggers clang compiler warning unused-but-set-variable (mac-osx)
- Student T CDF precision for large values
- vectorize binary log_sum_exp HOT 1
- Vectorized logical functions HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from math.