Drawing matrices with standard normal entries is so common and having to write the functor manually is such a pain (see stackoverflow.com/questions/6142576/sample-from-multivariate-normal-gaussian-distribution-in-c). Could a `DenseBase::Gaussian` be added to generate matrices with standard normal entries. Honestly, given how tedious it is to create new `NullaryExpr`s it'd be really useful to be able to generate matrices according to all of the distributions that C++ handles in the random library (normal, Poisson, Bernoulli, binomial, etc.). I don't think this is too hard to implement, it's basically just redoing `Random` for the different distributions, however, I'm new to the project and wanted to get peoples' opinions. Thanks.

I would somehow prefer merely to simplify the construction of nullary expressions. I.e., having an arbitrary functor object make the following valid: RNG rng; // random number generator which only needs to provide operator() MatrixXd A = MatrixXd::Nullary(rows, cols, rng); MatrixXd B; B.setNullary(rows, cols, rng); // alternative syntax (suggestion) Currently, custom nullary functors must provide both operator() and packetOp; both have to accept two indexes and must be const (which requires a small hack for RNGs which modify their state).

Simplifying how nullary expressions are constructed would be great as an alternative. I will leave this to those with more experience for now, but this would make doing a lot of statistical computing and machine learning much easier. Thanks.

it's not that complicated: #include <Eigen/Sparse> #include <iostream> #include <random> using namespace Eigen; int main() { std::default_random_engine generator; std::poisson_distribution<int> distribution(4.1); auto poisson = [&] (int) {return distribution(generator);}; RowVectorXi v = RowVectorXi::NullaryExpr(10, poisson ); std::cout << v << "\n"; }

That's not bad at all. The only example I could find was much more complicated. Thanks. This can probably be closed now.

I don't think we can do any better for 3.3, but let's keep the discussion open for 3.4.

I have implemented my own solution in which the matrices can be constructed with expressions of the form default_random_engine engine; MatrixXd mtx = MatrixXd::Distribution<normal_distribution<double>>(rows, cols, engine, mean, stddev); MatrixXi mtx_b = MatrixXi::Distribution<geometric_distribution<int>>(rows, cols, engine, p); Since this remains open, I wonder if you would like me to push it to the repository.

Sorry Daniel for not providing feedback for so long. I guess that's too specific, so I'm closing.

-- GitLab Migration Automatic Message -- This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/720.