Making mir.random.ndvariable.multivariateNormalVar create bigger data sets than 2
jmh530
john.michael.hall at gmail.com
Tue Feb 27 18:04:49 UTC 2018
On Tuesday, 27 February 2018 at 17:24:22 UTC, Nathan S. wrote:
> On Tuesday, 27 February 2018 at 16:42:00 UTC, Nathan S. wrote:
>> On Tuesday, 27 February 2018 at 15:08:42 UTC, jmh530 wrote:
>>> Nevertheless, it probably can't hurt to file an issue if you
>>> can't get something like the first one to work. I would think
>>> it should just work.
>>
>> The problem is that `mir.random.ndvariable` doesn't satisfy
>> `mir.random.variable.isRandomVariable!T`. ndvariables have a
>> slightly different interface from variables: instead of of
>> `rv(gen)` returning a result, `rv(gen, dst)` writes to dst. I
>> agree that the various methods for working with variables
>> should be enhanced to work with ndvariables.
>
> So, I see that the interface will have to be slightly different
> for ndvariable than for variable. With the exception of
> MultivariateNormalVariable, the same ndvariable instance can be
> called to fill output of any length "n", so one can't
> meaningfully create a range based on just the ndvariable
> without further specification. What would "front" return? For
> MultivariateNormalVariable "n" is constrained but it is a
> runtime parameter rather than a compile-time parameter.
>
> You'll want to ping @9il / Ilya Yaroshenko to discuss what the
> API should be like for this.
Honestly, I think the post above was my first use of mir.random,
so I'm nowhere near familiar enough at this point to add much
useful feedback. I'm definitely glad that it is getting worked on
and plan on using it in the future.
The only thing I would note is that there are not just
N-dimensional random variables, there are also NXN dimensional
random variables (not sure what else there could be, but it would
be significantly less popular). A Wishart distribution (used for
the distribution of covariance matrices) can be simulated by
multiplying the transpose of a multivariate random normal by
itself. This produces an NXN matrix. Ideally, the API could
handle this type of distribution as well.
Another type of distribution I sometimes see is from Bayesian
statistics (less common than typical distributions and could
probably be built on top of what is already in mir.random, but I
figured it couldn't hurt to bring it to your attention). A
normal-inverse-gamma distribution is one example of these types
of distributions. Simulating from this distribution would produce
a pair of the mean and variance, not just one value. This would
contrast with multivariate normal in that you would know it has
two dimensions at compile-time.
More information about the Digitalmars-d-learn
mailing list