source: trunk/yat/random/ContinuousDistribution.h @ 3898

Last change on this file since 3898 was 3898, checked in by Peter, 4 years ago

closes #858 and #869

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.3 KB
Line 
1#ifndef theplu_yat_random_continuous_distribution
2#define theplu_yat_random_continuous_distribution
3
4// $Id: ContinuousDistribution.h 3898 2020-03-31 02:02:42Z peter $
5
6/*
7  Copyright (C) 2020 Peter Johansson
8
9  This file is part of the yat library, http://dev.thep.lu.se/yat
10
11  The yat library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU General Public License as
13  published by the Free Software Foundation; either version 3 of the
14  License, or (at your option) any later version.
15
16  The yat library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20
21  You should have received a copy of the GNU General Public License
22  along with yat. If not, see <http://www.gnu.org/licenses/>.
23*/
24
25// to #define BOOST_ALLOW_DEPRECATED_HEADERS if needed
26#include <yat/utility/config_public.h>
27
28#include "Distribution.h"
29
30#include <boost/random/cauchy_distribution.hpp>
31#include <boost/random/chi_squared_distribution.hpp>
32#include <boost/random/extreme_value_distribution.hpp>
33#include <boost/random/fisher_f_distribution.hpp>
34#include <boost/random/gamma_distribution.hpp>
35#include <boost/random/lognormal_distribution.hpp>
36#include <boost/random/non_central_chi_squared_distribution.hpp>
37#include <boost/random/student_t_distribution.hpp>
38
39namespace theplu {
40namespace yat {
41namespace random {
42
43  /**
44     Proxy class between RNG and <a href="https://www.boost.org/doc/libs/1_72_0/doc/html/boost_random/reference.html#boost_random.reference.distributions">Boost Distributions</a>
45
46     \since New in yat 0.18
47   */
48  template<class RND>
49  class ContinuousDistribution :
50    public Distribution<RND, double>, public Continuous
51  {
52  public:
53    /**
54       \return a random number from distribution with parameters \a p.
55     */
56    double operator()(const typename RND::param_type& p) const
57    {
58      return const_cast<RND&>(this->distribution_)(this->urng_, p);
59    }
60
61
62    /**
63       \return a random number from distribution with parameters as in
64       param().
65     */
66    double operator()(void) const
67    {
68      return const_cast<RND&>(this->distribution_)(this->urng_);
69    }
70  };
71
72
73  /**
74     \see
75     <a href="https://www.boost.org/doc/libs/1_72_0/doc/html/boost/random/cauchy_distribution.html">
76     Boost cauchy_distribution</a>
77
78     \since New in yat 0.18
79   */
80  typedef ContinuousDistribution<boost::random::cauchy_distribution<> > Cauchy;
81
82  /**
83     \see
84     <a href="https://www.boost.org/doc/libs/1_72_0/doc/html/boost/random/chi_squared_distribution.html">
85     Boost chi_squared_distribution</a>
86
87     \since New in yat 0.18
88   */
89  typedef ContinuousDistribution<boost::random::chi_squared_distribution<> >
90  ChiSquared;
91
92  /**
93     \see
94     <a href="https://www.boost.org/doc/libs/1_72_0/doc/html/boost/random/extreme_value_distribution.html">
95     Boost extreme_value_distribution</a>
96
97     \since New in yat 0.18
98   */
99  typedef ContinuousDistribution<boost::random::extreme_value_distribution<> >
100  ExtremeValue;
101
102  /**
103     \see
104     <a href="https://www.boost.org/doc/libs/1_72_0/doc/html/boost/random/fisher_f_distribution.html">
105     Boost fisher_f_distribution</a>
106
107     \since New in yat 0.18
108   */
109  typedef ContinuousDistribution<boost::random::fisher_f_distribution<> >
110  FisherF;
111
112  /**
113     \see
114     <a href="https://www.boost.org/doc/libs/1_72_0/doc/html/boost/random/gamma_distribution.html">
115     Boost gamma_distribution</a>
116
117     \since New in yat 0.18
118   */
119  typedef ContinuousDistribution<boost::random::gamma_distribution<> > Gamma;
120
121  /**
122     \see
123     <a href="https://www.boost.org/doc/libs/1_72_0/doc/html/boost/random/lognormal_distribution.html">
124     Boost lognormal_distribution</a>
125
126     \since New in yat 0.18
127   */
128  typedef ContinuousDistribution<boost::random::lognormal_distribution<> >
129  Lognormal;
130
131  /**
132     \see
133     <a href="https://www.boost.org/doc/libs/1_72_0/doc/html/boost/random/non_central_chi_squared_distribution.html">
134     Boost non_central_chi_squared_distribution</a>
135
136     \since New in yat 0.18
137   */
138  typedef
139  ContinuousDistribution<boost::random::non_central_chi_squared_distribution<> >
140  NonCentralChiSquared;
141
142  /**
143     \see
144     <a href="https://www.boost.org/doc/libs/1_72_0/doc/html/boost/random/student_t_distribution.html">
145     Boost student_t_distribution</a>
146
147     \since New in yat 0.18
148   */
149  typedef ContinuousDistribution<boost::random::student_t_distribution<> >
150  StudentT;
151
152}}} // of namespace random, yat, and theplu
153
154#endif
Note: See TracBrowser for help on using the repository browser.