Boost logo

Boost :

Subject: Re: [boost] [math] & [random] distribution object compatibility
From: Thijs van den Berg (thijs_at_[hidden])
Date: 2014-04-13 14:46:07


> AMDG
>
> On 04/13/2014 07:36 AM, Thijs van den Berg wrote:
>> Boost [random] has probability distribution objects for drawing random samples of those distributions. Boost [math] also has probability distributions, those provide free functions for computing properties of the distributions, like mean, pdf etc.
>>
>> I like the free function design of math variant e.g. it uses pdf(distribution,x) and I was wondering why this hasn’t been adopt in C++11 for <random>? To me a free function syntax like random(distribution,engine) would make sense. It would align with the fact that C++11 has added begin(container) and end(container) free functions.
>>
>> I think it’s a bit inconvenient to have two libs that both contain probability distributions.
>
> They need to be separate types, because efficient
> algorithms for generating random variates often require
> extra members that are useless for anything else.
>
> At one time I considered trying to make param_type a
> typedef for the corresponding Boost.Math distribution,
> but the required interface is a bit of a problem.
that’s clear.
In [random] the algorithms are inside the distribution class, in [math] the algorithms are outside the class, inside non-member functions (like pdf). The distributions in [math] are hardly more than a param_type. If in [random] the algorithms would have been moved to a random non-member function (or functor) then both libs could use a shared minimalistic distribution type that would be be very much like param_type. The proposed random non-member function/functor would be very similar to the “random_distribution::operator()(eng, param_type) const” with param_type something shared by both libs.

>
>> Especially since I’m hoping that boost/math would some day en up in the standard? One way we could integrate the two libs is by adding a random(distribution,engine) free function to the math lib which would accept both distribution objects from the random lib and the math lib. This however could stimulate users in writing less C++11 portable code.
>>
>> My questions are:
>> * Why wasn’t the free function syntax adopted in C++11? Perhaps because of performance options?
>> * Is there an effort to integrate the distributions in math and random within boost?
>> * Are there concrete plans to add elements of math to the C++ standard? We already have <random> now, I would love more.
>>
>
> In Christ,
> Steven Watanabe
>
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk