multi-variate distribution
Daniel Krügler
daniel.kruegler@gmail.com
Mon Sep 3 06:15:00 GMT 2012
2012/9/3 Ulrich Drepper <drepper@gmail.com>:
> The distribution functions included so far are only the basic ones.
> For simulations what is needed are multiple variables and they usually
> are correlated. This is what multi-variate distributions are about.
> The most commonly used is the multi-variate normal distribution. The
> attached patch implements such a distribution.
[..]
> Any opinions? Otherwise I'll submit the patch for inclusion.
I don't think that
template<typename _InputIterator1, typename _InputIterator2>
+ param_type(_InputIterator1 __meanbegin, _InputIterator1 __meanend,
+ _InputIterator2 __varcovbegin, _InputIterator2 __varcovend)
should name the parameters as _InputIterator1 and _InputIterator2, resp,
because the code does multi-pass traversal. Suggested change would
be
template<typename _ForwardIterator1, typename _ForwardIterator2>
+ param_type(_ForwardIterator1 __meanbegin, _ForwardIterator1 __meanend,
+ _ForwardIterator2 __varcovbegin, _ForwardIterator2 __varcovend)
This also means that e.g.
+ template<typename _InputIterator1, typename _InputIterator2>
+ normal_mv_distribution(_InputIterator1 __meanbegin,
+ _InputIterator1 __meanend,
+ _InputIterator2 __varcovbegin,
+ _InputIterator2 __varcovend)
should change its parameter names.
When looking into
template<std::size_t _Dimen, typename _RealType>
+ template<typename _InputIterator1, typename _InputIterator2>
+ void normal_mv_distribution<_Dimen, _RealType>::param_type::
+ _M_init_full(_InputIterator1 __meanbegin, _InputIterator1 __meanend,
+ _InputIterator2 __varcovbegin, _InputIterator2 __varcovend)
it seems that _InputIterator1 is properly chosen, but _InputIterator2 not: The
code imposes random access traversal. Is this really necessary? IMO,
the code could simply use advance on __varcovbegin.
- Daniel
More information about the Libstdc++
mailing list