Boost logo

Boost Users :

Subject: Re: [Boost-users] students_t distribution with mt19937
From: Kraus Philipp (philipp.kraus_at_[hidden])
Date: 2010-07-20 11:20:57


Am 20.07.2010 um 17:01 Steven Watanabe:

> AMDG
>
> Kraus Philipp wrote:
>> I use some distributions with this code:
>> boost::normal_distribution<> l_range(p_mean, p_sd);
>> static boost::mt19937 l_random(static_cast<std::size_t>(time(0)));
>> boost::variate_generator<boost::mt19937&,
>> boost::normal_distribution<> > l_noise( l_random, l_range );
>>
>> I get my value with l_noise() and it works without any problem.
>>
>> I would like to create now a student_t distribution with
>> boost::math::students_t_distribution<T> l_range(p_v);
>> static boost::mt19937 l_random(static_cast<std::size_t>(time(0)));
>> boost::variate_generator<boost::mt19937&,
>> boost::math::students_t_distribution<> > l_noise( l_random,
>> l_range );
>>
>> If I run my l_noise() I got a compiler error: error: no match for
>> call to
>> '(boost
>> ::variate_generator<boost::random::mersenne_twister<uint32_t, 32,
>> 624, 397, 31, 2567483615u, 11, 7, 2636928640u, 15, 4022730752u, 18,
>> 3346425566u>&, boost::math::students_t_distribution<double,
>> boost
>> ::math::policies::policy<boost::math::policies::default_policy,
>> boost::math::policies::default_policy,
>> boost::math::policies::default_policy,
>> boost::math::policies::default_policy,
>> boost::math::policies::default_policy,
>> boost::math::policies::default_policy,
>> boost::math::policies::default_policy,
>> boost::math::policies::default_policy,
>> boost::math::policies::default_policy,
>> boost::math::policies::default_policy,
>> boost::math::policies::default_policy,
>> boost::math::policies::default_policy,
>> boost::math::policies::default_policy> > >) ()'
>>
>> Can anyone help me please to understand my mistake while using the
>> students_t distribution? I think I need the mt19937 for creating
>> random values and the variate_generator to create a "distribution
>> value"
>
> Boost.Math and Boost.Random have different concepts for distributions.
> The easiest way to use boost::math::students_t_distribution, with
> Boost.Random
> is to pass uniform variates to quantile.
>
> boost::math::students_t_distribution<T> l_range(p_v);
> static boost::mt19937 l_random(static_cast<std::size_t>(time(0)));
> boost::variate_generator<boost::mt19937&, boost::uniform_01<T> >
> l_uniform( l_random, boost::uniform_01<T>() );
>
> T val = quantile(l_rangle, l_uniform());

Thanks Steven, I had thought that the two are compatible.

Phil


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net