mirror of
https://gitlab.com/fbb-git/cppannotations
synced 2024-11-16 07:48:44 +01:00
Added descriptions and examples of various stat. distributions
git-svn-id: https://cppannotations.svn.sourceforge.net/svnroot/cppannotations/trunk@466 f6dd340e-d3f9-0310-b409-bdd246841980
This commit is contained in:
parent
2faa106a66
commit
cb047ed8d4
21 changed files with 559 additions and 146 deletions
|
@ -19,20 +19,10 @@ Constructor, members and example:
|
|||
returning tt(true);
|
||||
itt(double p() const)nl()
|
||||
returns tt(prob);
|
||||
itt(param_type param() const)nl()
|
||||
returns the object's tt(param_type) structure;
|
||||
itt(void param(const param_type ¶m))
|
||||
redefines the probability of the distribution;
|
||||
itt(result_type min() const)nl()
|
||||
returns tt(false);
|
||||
itt(result_type max() const)nl()
|
||||
returns tt(true);
|
||||
itt(template<typename URNG> result_type operator()(URNG &urng))nl()
|
||||
returns the next random value from the bernoulli distribution
|
||||
itt(template<typename URNG> result_type operator())nl()
|
||||
tt((URNG &urng, param_type ¶m))nl()
|
||||
returns the next random value from a bernoulli distribution
|
||||
initialized by the provided tt(param) struct.
|
||||
it() Example:
|
||||
verbinclude(stl/examples/bernoulli.cc)
|
||||
)
|
||||
|
|
|
@ -29,20 +29,10 @@ Constructor, members and example:
|
|||
returns tt(trials);
|
||||
itt(double p() const)nl()
|
||||
returns tt(prob);
|
||||
itt(param_type param() const)nl()
|
||||
returns the object's tt(param_type) structure;
|
||||
itt(void param(const param_type ¶m))
|
||||
redefines the parameters of the distribution;
|
||||
itt(result_type min() const)nl()
|
||||
returns the distribution's lower bound (tt(0));
|
||||
itt(result_type min() const) nl()
|
||||
returns 0;
|
||||
itt(result_type max() const)nl()
|
||||
returns the distribution's upper bound (tt(trials));
|
||||
itt(template<typename URNG> result_type operator()(URNG &urng))nl()
|
||||
returns the next random value from the binomial distribution
|
||||
itt(template<typename URNG> result_type operator())nl()
|
||||
tt((URNG &urng, param_type ¶m))nl()
|
||||
returns the next random value from a binomial distribution
|
||||
initialized by the provided tt(param) struct.
|
||||
returns tt(trials);
|
||||
it() Example:
|
||||
verbinclude(stl/examples/binomial.cc)
|
||||
)
|
||||
|
|
45
yo/stl/cauchy.yo
Normal file
45
yo/stl/cauchy.yo
Normal file
|
@ -0,0 +1,45 @@
|
|||
The ti(cauchy_distribution<RealType = double>) looks similar to a normal
|
||||
distribution. But cauchy distributions have heavier tails. When studying
|
||||
hypothesis tests that assume normality, seeing how the tests perform on data
|
||||
from a Cauchy distribution is a good indicator of how sensitive the tests are
|
||||
to heavy-tail departures from normality.
|
||||
|
||||
The mean and standard deviation of the Cauchy distribution are undefined.
|
||||
|
||||
|
||||
Defined types:
|
||||
verb(
|
||||
typedef IntType result_type;
|
||||
|
||||
struct param_type
|
||||
{
|
||||
explicit param_type(RealType a = RealType(0),
|
||||
RealType b = RealType(1));
|
||||
|
||||
double a() const;
|
||||
double b() const;
|
||||
};
|
||||
)
|
||||
|
||||
Constructor, members and example:
|
||||
itemization(
|
||||
itt(cauchy_distribution(RealType a = RealType(0),
|
||||
RealType b = RealType(1)))
|
||||
constructs a cauchy distribution with specified tt(a) and tt(b)
|
||||
parameters.
|
||||
itt(cauchy_distribution(param_type const ¶m))
|
||||
constructs a cauchy distribution according to the values stored in
|
||||
the tt(param) struct.
|
||||
itt(IntType a() const)nl()
|
||||
returns the distribution's tt(a) parameter;
|
||||
itt(IntType a() const)nl()
|
||||
returns the distribution's tt(b) parameter;
|
||||
itt(result_type min() const)nl()
|
||||
returns the smallest positive tt(result_type) value;
|
||||
itt(result_type max() const)nl()
|
||||
returns the maximum value of tt(result_type);
|
||||
it() Example:
|
||||
verbinclude(stl/examples/cauchy.cc)
|
||||
)
|
||||
|
||||
|
38
yo/stl/chisquared.yo
Normal file
38
yo/stl/chisquared.yo
Normal file
|
@ -0,0 +1,38 @@
|
|||
The ti(chi_squared_distribution<RealType = double>) with tt(n) degrees of
|
||||
freedom is the distribution of a sum of the squares of tt(n) independent
|
||||
standard normal random variables.
|
||||
|
||||
The chi-squared distribution is used, e.g., when testing the goodness of fit
|
||||
of an observed distribution to a theoretical one.
|
||||
|
||||
Defined types:
|
||||
verb(
|
||||
typedef RealType result_type;
|
||||
|
||||
struct param_type
|
||||
{
|
||||
explicit param_type(RealType n = RealType(1));
|
||||
|
||||
RealType n() const;
|
||||
};
|
||||
)
|
||||
|
||||
Constructor, members and example:
|
||||
itemization(
|
||||
itt(chi_squared_distribution(RealType n = 1))
|
||||
constructs a chi_squared distribution with specified number of degrees
|
||||
of freedom.
|
||||
itt(chi_squared_distribution(param_type const ¶m))
|
||||
constructs a chi_squared distribution according to the value stored in
|
||||
the tt(param) struct;
|
||||
itt(IntType n() const)nl()
|
||||
returns the distribution's degrees of freedom;
|
||||
itt(result_type min() const)nl()
|
||||
returns 0;
|
||||
itt(result_type max() const)nl()
|
||||
returns the maximum value of tt(result_type);
|
||||
it() Example:
|
||||
verbinclude(stl/examples/chisquared.cc)
|
||||
)
|
||||
|
||||
|
20
yo/stl/examples/cauchy.cc
Normal file
20
yo/stl/examples/cauchy.cc
Normal file
|
@ -0,0 +1,20 @@
|
|||
#include <iostream>
|
||||
#include <ctime>
|
||||
#include <random>
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
std::mt19937 engine(time(0));
|
||||
std::cauchy_distribution<> dist;
|
||||
|
||||
for (size_t idx = 0; idx < 10; ++idx)
|
||||
std::cout << "a random value: " << dist(engine) << "\n";
|
||||
|
||||
cout << '\n' <<
|
||||
dist.min() << " " << dist.max() << '\n';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
20
yo/stl/examples/chisquared.cc
Normal file
20
yo/stl/examples/chisquared.cc
Normal file
|
@ -0,0 +1,20 @@
|
|||
#include <iostream>
|
||||
#include <ctime>
|
||||
#include <random>
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
std::mt19937 engine(time(0));
|
||||
std::chi_squared_distribution<> dist(10);
|
||||
|
||||
for (size_t idx = 0; idx < 10; ++idx)
|
||||
std::cout << "a random value: " << dist(engine) << "\n";
|
||||
|
||||
cout << '\n' <<
|
||||
dist.min() << " " << dist.max() << '\n';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
20
yo/stl/examples/exponential.cc
Normal file
20
yo/stl/examples/exponential.cc
Normal file
|
@ -0,0 +1,20 @@
|
|||
#include <iostream>
|
||||
#include <ctime>
|
||||
#include <random>
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
std::mt19937 engine(time(0));
|
||||
std::exponential_distribution<> dist;
|
||||
|
||||
for (size_t idx = 0; idx < 10; ++idx)
|
||||
std::cout << "a random value: " << dist(engine) << "\n";
|
||||
|
||||
cout << '\n' <<
|
||||
dist.min() << " " << dist.max() << '\n';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
20
yo/stl/examples/lognormal.cc
Normal file
20
yo/stl/examples/lognormal.cc
Normal file
|
@ -0,0 +1,20 @@
|
|||
#include <iostream>
|
||||
#include <ctime>
|
||||
#include <random>
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
std::mt19937 engine(time(0));
|
||||
std::lognormal_distribution<> dist;
|
||||
|
||||
for (size_t idx = 0; idx < 10; ++idx)
|
||||
std::cout << "a random value: " << dist(engine) << "\n";
|
||||
|
||||
cout << '\n' <<
|
||||
dist.min() << " " << dist.max() << '\n';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
20
yo/stl/examples/normal.cc
Normal file
20
yo/stl/examples/normal.cc
Normal file
|
@ -0,0 +1,20 @@
|
|||
#include <iostream>
|
||||
#include <ctime>
|
||||
#include <random>
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
std::mt19937 engine(time(0));
|
||||
std::normal_distribution<> dist;
|
||||
|
||||
for (size_t idx = 0; idx < 10; ++idx)
|
||||
std::cout << "a random value: " << dist(engine) << "\n";
|
||||
|
||||
cout << '\n' <<
|
||||
dist.min() << " " << dist.max() << '\n';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
20
yo/stl/examples/poisson.cc
Normal file
20
yo/stl/examples/poisson.cc
Normal file
|
@ -0,0 +1,20 @@
|
|||
#include <iostream>
|
||||
#include <ctime>
|
||||
#include <random>
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
std::mt19937 engine(time(0));
|
||||
std::poisson_distribution<> dist(5);
|
||||
|
||||
for (size_t idx = 0; idx < 10; ++idx)
|
||||
std::cout << "a random value: " << dist(engine) << "\n";
|
||||
|
||||
cout << '\n' <<
|
||||
dist.min() << " " << dist.max() << '\n';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
20
yo/stl/examples/uniformint.cc
Normal file
20
yo/stl/examples/uniformint.cc
Normal file
|
@ -0,0 +1,20 @@
|
|||
#include <iostream>
|
||||
#include <ctime>
|
||||
#include <random>
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
std::mt19937 engine(time(0));
|
||||
std::uniform_int_distribution<> dist(100, 200);
|
||||
|
||||
for (size_t idx = 0; idx < 10; ++idx)
|
||||
std::cout << "a random value: " << dist(engine) << "\n";
|
||||
|
||||
cout << '\n' <<
|
||||
dist.min() << " " << dist.max() << '\n';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
16
yo/stl/examples/uniformreal.cc
Normal file
16
yo/stl/examples/uniformreal.cc
Normal file
|
@ -0,0 +1,16 @@
|
|||
#include <iostream>
|
||||
#include <ctime>
|
||||
#include <random>
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
std::mt19937 engine(time(0));
|
||||
std::uniform_real_distribution<> dist;
|
||||
|
||||
for (size_t idx = 0; idx < 10; ++idx)
|
||||
std::cout << "a random value: " << dist(engine)<< "\n";
|
||||
|
||||
cout << '\n' <<
|
||||
dist.min() << " " << dist.max() << '\n';
|
||||
}
|
40
yo/stl/exponential.yo
Normal file
40
yo/stl/exponential.yo
Normal file
|
@ -0,0 +1,40 @@
|
|||
The ti(exponential_distribution<ReadType = double>) is used to describe the
|
||||
lengths between events that can be modelled with a homogeneous Poisson
|
||||
process. It can be interpreted as the continuous form of the
|
||||
geometric distribution.
|
||||
|
||||
Its parameter tt(prob) defines the distribution's em(lamda) parameter, called
|
||||
its em(rate) parameter.It has two parameters, tt(alpha) and tt(beta). Its
|
||||
expected value and standard deviation are both tt(1 / lambda).
|
||||
|
||||
Defined types:
|
||||
verb(
|
||||
typedef RealType result_type;
|
||||
|
||||
struct param_type
|
||||
{
|
||||
explicit param_type(RealType lambda = RealType(1));
|
||||
|
||||
RealType lambda() const;
|
||||
};
|
||||
)
|
||||
|
||||
Constructor, members and example:
|
||||
itemization(
|
||||
itt(exponential_distribution(RealType alpha = 1, RealType beta = 1))
|
||||
constructs an exponential distribution with specified tt(lambda)
|
||||
parameter.
|
||||
itt(exponential_distribution(param_type const ¶m))
|
||||
constructs an exponential distribution according to the value stored in
|
||||
the tt(param) struct.
|
||||
itt(IntType lambda() const)nl()
|
||||
returns the distribution's tt(lambda) parameter;
|
||||
itt(result_type min() const)nl()
|
||||
returns 0;
|
||||
itt(result_type max() const)nl()
|
||||
returns the maximum value of tt(result_type);
|
||||
it() Example:
|
||||
verbinclude(stl/examples/exponential.cc)
|
||||
)
|
||||
|
||||
|
|
@ -32,20 +32,10 @@ Constructor, members and example:
|
|||
returns the distribution's tt(alpha) parameter;
|
||||
itt(IntType beta() const)nl()
|
||||
returns the distribution's tt(beta) parameter;
|
||||
itt(param_type param() const)nl()
|
||||
returns the object's tt(param_type) structure;
|
||||
itt(void param(const param_type ¶m))
|
||||
redefines the parameters of the distribution;
|
||||
itt(result_type min() const)nl()
|
||||
returns the distribution's lower bound (tt(0));
|
||||
returns 0;
|
||||
itt(result_type max() const)nl()
|
||||
returns the distribution's upper bound (tt(trials));
|
||||
itt(template<typename URNG> result_type operator()(URNG &urng))nl()
|
||||
returns the next random value from the gamma distribution
|
||||
itt(template<typename URNG> result_type operator())nl()
|
||||
tt((URNG &urng, param_type ¶m))nl()
|
||||
returns the next random value from a gamma distribution
|
||||
initialized by the provided tt(param) struct.
|
||||
returns the maximum value of tt(result_type);
|
||||
it() Example:
|
||||
verbinclude(stl/examples/gamma.cc)
|
||||
)
|
||||
|
|
43
yo/stl/lognormal.yo
Normal file
43
yo/stl/lognormal.yo
Normal file
|
@ -0,0 +1,43 @@
|
|||
The ti(lognormal_distribution<RealType = double>) is a probability
|
||||
distribution of a random variable whose logarithm is normally distributed. If
|
||||
a random variable tt(X) has a normal distribution, then tt(Y = e)sups(X) has a
|
||||
log-normal distribution.
|
||||
|
||||
It has two parameters, em(m) and em(s) representing, respectively, the mean
|
||||
and standard deviation of tt(ln(X)).
|
||||
|
||||
|
||||
Defined types:
|
||||
verb(
|
||||
typedef RealType result_type;
|
||||
|
||||
struct param_type
|
||||
{
|
||||
explicit param_type(RealType m = RealType(0),
|
||||
RealType s = RealType(1));
|
||||
|
||||
RealType m() const;
|
||||
RealType s() const;
|
||||
};
|
||||
)
|
||||
|
||||
Constructor, members and example:
|
||||
itemization(
|
||||
itt(lognormal_distribution(RealType m = 0, RealType s = 1))
|
||||
constructs a log-normal distribution for a random variable whose mean
|
||||
and standard deviation is, respectively, tt(m) and tt(s).
|
||||
itt(lognormal_distribution(param_type const ¶m)) constructs a
|
||||
log-normal distribution according to the values stored in the
|
||||
tt(param) struct.
|
||||
itt(IntType m() const)nl()
|
||||
returns the distribution's tt(m) parameter;
|
||||
itt(IntType stddev() const)nl()
|
||||
returns the distribution's tt(s) parameter;
|
||||
itt(result_type min() const)nl()
|
||||
returns 0;
|
||||
itt(result_type max() const)nl()
|
||||
returns the maximum value of tt(result_type);
|
||||
it() Example:
|
||||
verbinclude(stl/examples/lognormal.cc)
|
||||
)
|
||||
|
42
yo/stl/normal.yo
Normal file
42
yo/stl/normal.yo
Normal file
|
@ -0,0 +1,42 @@
|
|||
The ti(normal_distribution<RealType = double>) is commonly used in science to
|
||||
describe complex phenomena. When predicting variables prediction errors are
|
||||
commonly assumed to be normally distributed.
|
||||
|
||||
It has two parameters, em(mean) and em(standard deviation).
|
||||
|
||||
|
||||
Defined types:
|
||||
verb(
|
||||
typedef RealType result_type;
|
||||
|
||||
struct param_type
|
||||
{
|
||||
explicit param_type(RealType mean = RealType(0),
|
||||
RealType stddev = RealType(1));
|
||||
|
||||
RealType mean() const;
|
||||
RealType stddev() const;
|
||||
};
|
||||
)
|
||||
|
||||
Constructor, members and example:
|
||||
itemization(
|
||||
itt(normal_distribution(RealType mean = 0, RealType stddev = 1))
|
||||
constructs a normal distribution with specified tt(mean) and tt(stddev)
|
||||
parameters. The default parameter values define the
|
||||
emi(standard normal distribution);
|
||||
itt(normal_distribution(param_type const ¶m))
|
||||
constructs a normal distribution according to the values stored in
|
||||
the tt(param) struct.
|
||||
itt(IntType mean() const)nl()
|
||||
returns the distribution's tt(mean) parameter;
|
||||
itt(IntType stddev() const)nl()
|
||||
returns the distribution's tt(stddev) parameter;
|
||||
itt(result_type min() const)nl()
|
||||
returns the lowest positive value of tt(result_type);
|
||||
itt(result_type max() const)nl()
|
||||
returns the maximum value of tt(result_type);
|
||||
it() Example:
|
||||
verbinclude(stl/examples/normal.cc)
|
||||
)
|
||||
|
42
yo/stl/poisson.yo
Normal file
42
yo/stl/poisson.yo
Normal file
|
@ -0,0 +1,42 @@
|
|||
The ti(poisson_distribution<IntType = int>) is used to model the probability
|
||||
of a number of events occurring in a fixed period of time if these events
|
||||
occur with a known probability and independently of the time since the last
|
||||
event.
|
||||
|
||||
It has one parameter, tt(mean), specifying the expected number of events in
|
||||
the interval under consideration. E.g., if on average 2 events are observed in
|
||||
a one-minute interval and the duration of the interval under study is
|
||||
10 minutes then tt(mean = 20).
|
||||
|
||||
|
||||
Defined types:
|
||||
verb(
|
||||
typedef IntType result_type;
|
||||
|
||||
struct param_type
|
||||
{
|
||||
explicit param_type(double meaan = 1.0);
|
||||
|
||||
double mean() const;
|
||||
};
|
||||
)
|
||||
|
||||
Constructor, members and example:
|
||||
itemization(
|
||||
itt(poisson_distribution(RealType mean = 1))
|
||||
constructs a poisson distribution with specified tt(mean)
|
||||
parameter.
|
||||
itt(poisson_distribution(param_type const ¶m))
|
||||
constructs a poisson distribution according to the values stored in
|
||||
the tt(param) struct.
|
||||
itt(IntType mean() const)nl()
|
||||
returns the distribution's tt(mean) parameter;
|
||||
itt(result_type min() const)nl()
|
||||
returns 0;
|
||||
itt(result_type max() const)nl()
|
||||
returns the maximum value of tt(result_type);
|
||||
it() Example:
|
||||
verbinclude(stl/examples/poisson.cc)
|
||||
)
|
||||
|
||||
|
|
@ -1,12 +1,36 @@
|
|||
Before the statistical distributions and accompanying random number
|
||||
generators can be used the tthi(random) header file must have been included.
|
||||
|
||||
The C++0x standard introduces several standard mathematical (statistical)
|
||||
distributions into the STL. These distributions allow programmers to obtain
|
||||
randomly selected values from a specified distribution.
|
||||
randomly selected values from a selected distribution.
|
||||
|
||||
Using these distrbutions is based on new randum number generator functions,
|
||||
differing from the traditional ti(rand) function provided by the bf(C)
|
||||
standard library. These random number generators are used to produce
|
||||
pseudo-random numbers, which are then filtered through a particular
|
||||
distribution to obtain values that are randomly selected from the specified
|
||||
distribution.
|
||||
These statistical distrbutions need to be provided with a random number
|
||||
generating object. Several of such random number generating objects are
|
||||
provided, extending the traditional ti(rand) function that is part of the
|
||||
bf(C) standard library.
|
||||
|
||||
Currently not all mathematical distributions have been implemented.
|
||||
These random number generating objects produce pseudo-random numbers, which
|
||||
are then processed by the statistical distribution to obtain values that are
|
||||
randomly selected from the specified distribution.
|
||||
|
||||
Although the STL offers various statistical distributions their functionality
|
||||
is fairly limited. The distributions allow us to obtain a random number from
|
||||
these distributions, but
|
||||
i(probility density function)s
|
||||
or
|
||||
i(cumulative distribution function)s
|
||||
are currently not provided by the STL. These functions (distributions as well
|
||||
as the density and the cumulative distribution functions) are, however,
|
||||
available in other libraries, like the
|
||||
turl(boost math library)(http://www.boost.org/) (specifically:
|
||||
lurl(http://www.boost.org/doc/libs/1_44_0/libs/math/doc/sf_and_dist/\
|
||||
html/index.html)).
|
||||
|
||||
It is beyond the scope of the annotations() to discuss the mathematical
|
||||
characteristics of the various distributions that are supported by the C++0x
|
||||
standard. The interested reader is referred to the pertinent mathematical
|
||||
textbooks (like Stuart and Ord's (2009)
|
||||
hi(Stuart, A. & Ord, K)
|
||||
emi(Kendall's Advanced Theory of Statistics), Wiley) or to web-locations
|
||||
like lurl(http://en.wikipedia.org/wiki/Bernoulli_distribution).
|
||||
|
|
|
@ -1,115 +1,46 @@
|
|||
Before the statistical distributions and accompanying random number
|
||||
generators can be used the tthi(random) header file must have been included.
|
||||
|
||||
The following statistical distributions are available (an example showing their
|
||||
use is provided with each distribution presented below). More information
|
||||
about the distributions mentioned below can be found at web-locations like
|
||||
lurl(http://en.wikipedia.org/wiki/Bernoulli_distribution).
|
||||
|
||||
Although the STL offers various statistical distributions their functionality
|
||||
is rather basic. The distributions allow us to obtain a random number from
|
||||
these distributions, but
|
||||
i(probility density function)s
|
||||
or
|
||||
i(cumulative distribution function)s
|
||||
are currently not provided by the STL. These functions (distributions as well
|
||||
as the density and the cumulative distribution functions) are, however,
|
||||
available in other libraries, like the
|
||||
turl(boost math library)(http://www.boost.org/) (specifically:
|
||||
lurl(http://www.boost.org/doc/libs/1_44_0/libs/math/doc/sf_and_dist/\
|
||||
html/index.html)).
|
||||
|
||||
Below, ti(RNG) is used to indicate a em(Random Number Generator) and ti(URNG)
|
||||
is used to indicate a em(Uniform Random Number Generator)
|
||||
In the following sections the various statistical distributions that are
|
||||
supported by the C++0x standard are covered. The notation ti(RNG) is used to
|
||||
indicate a em(Random Number Generator) and ti(URNG) is used to indicate a
|
||||
em(Uniform Random Number Generator). With each distribution a
|
||||
tt(struct param_type) is defined containing the distribution's parameters. The
|
||||
organization of these tt(param_type) structs depends on (and is described
|
||||
at) the actual distribution.
|
||||
|
||||
All distributions offer the following members (em(result_type) refers to
|
||||
the type name of the values returned by the distribution;
|
||||
em(name_distribution) refers to the type name of the mathematical
|
||||
distribution, e.g., tt(bernoulli_distribution)):
|
||||
the type name of the values returned by the distribution:
|
||||
itemization(
|
||||
itt(result_type operator()(RNG):)
|
||||
The next randomly generated value is returned, providing the member
|
||||
with a random number generator as its argument;
|
||||
itt(result_type max() const)nl()
|
||||
returns the distribution's least upper bound;
|
||||
itt(result_type min() const)nl()
|
||||
returns the distribution's greatest lower bound;
|
||||
itt(param_type param() const)nl()
|
||||
returns the object's tt(param_type) struct;
|
||||
itt(void param(const param_type ¶m))
|
||||
redefines the parameters of the distribution;
|
||||
itt(void reset():)
|
||||
Clears all of its cached values;
|
||||
clears all of its cached values;
|
||||
)
|
||||
|
||||
All distributions offer the following operators (em(distribution-name)
|
||||
should be replaced by the name of the intended distribution, e.g.,
|
||||
tt(normal_distribution)):
|
||||
itemization(
|
||||
itt(template<typename URNG> result_type operator()(URNG &urng))nl()
|
||||
returns the next random value from the statistical distribution, with
|
||||
the function object tt(urng) returning the next random number selected
|
||||
from a uniform random distribution;
|
||||
itt(template<typename URNG> result_type operator())nl()
|
||||
tt((URNG &urng, param_type ¶m))nl() returns the next random value
|
||||
from the statistical distribution initialize with the parameters
|
||||
provided by the tt(param) struct. The function object tt(urng)
|
||||
returns the next random number selected from a uniform random
|
||||
distribution;
|
||||
itt(std::istream &operator<<(std::istream &in,
|
||||
distribution-name &object):)
|
||||
The parameters of the distribution are extracted from an
|
||||
tt(std::istream);
|
||||
itt(std::ostream &operator<<(std::ostream &out,
|
||||
bernoulli_distribution const &bd):)
|
||||
distribution-name const &bd):)
|
||||
The parameters of the distribution are inserted into an
|
||||
tt(std::ostream)
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
it() ti(exponential_distribution<Type = double>)nl()
|
||||
tt(Type): the parameter of the exponential distribution.nl()
|
||||
Random integral values are generated according to the
|
||||
specified exponential distribution+nl()
|
||||
Constructor:
|
||||
itemization(
|
||||
itt(exponential_distribution<IntType, Type>(Type lambda =
|
||||
Type(1)))nl()
|
||||
)
|
||||
|
||||
it() ti(normal_distribution<Type = double>)nl()
|
||||
tt(Type): the type of the generated random value (by default
|
||||
tt(double)). nl()
|
||||
Constructor:
|
||||
itemization(
|
||||
itt(normal_distribution<Type>(ReadType mean = Type(0),
|
||||
Type sigma = Type(1)))nl()
|
||||
)
|
||||
|
||||
it() ti(poisson_distribution<IntType = int, RealType = double>)nl()
|
||||
tt(IntType): the type of the generated random value (by default
|
||||
tt(int)). nl()
|
||||
tt(RealType): the type of the parameter of the distribution (by default
|
||||
tt(double)). nl()
|
||||
Random integral values are generated that are distributed
|
||||
according to a poisson distribution with parameter tt(mean).
|
||||
Constructor:
|
||||
itemization(
|
||||
itt(poisson_distribution<IntType, RealType>(RealType mean =
|
||||
RealType(1)))nl()
|
||||
)
|
||||
|
||||
it() ti(uniform_int<Type = int>)nl()
|
||||
tt(Type): the type of the generated random value (by default
|
||||
tt(int)). nl()
|
||||
Random integral values are generated that are uniformly
|
||||
distributed over a certain range.nl()
|
||||
Constructor:
|
||||
itemization(
|
||||
itt(uniform_int<Type>(Type min = 0, Type max = 9))nl()
|
||||
)
|
||||
Additional member:
|
||||
itemization(
|
||||
itt(Type operator()(RandomNumberGenerator), Type upper)nl()
|
||||
Random numbers are generated in the range rangett(0)(upper)
|
||||
(half-inclusive).
|
||||
)
|
||||
|
||||
it() ti(uniform_real<Type = real>)nl()
|
||||
tt(Type): the type of the generated random value (by default
|
||||
tt(real)). nl()
|
||||
Random real values are generated that are uniformly
|
||||
distributed over a certain range.nl()
|
||||
Constructor:
|
||||
itemization(
|
||||
itt(uniform_real<Type>(Type min = Type(0), Type max = Type(1)))nl()
|
||||
)
|
||||
Note: the current implementation generates
|
||||
verb(
|
||||
GRN * (max - min) + min
|
||||
)
|
||||
which might not be what you'd expect.
|
||||
)
|
||||
|
||||
|
|
40
yo/stl/uniformint.yo
Normal file
40
yo/stl/uniformint.yo
Normal file
|
@ -0,0 +1,40 @@
|
|||
The ti(uniform_int_distribution<IntType = int>) can be used to select integral
|
||||
values randomly from a range of uniformly distributed integral values.
|
||||
|
||||
It has two parameters, tt(a) and tt(b), specifying, respectively, the lowest
|
||||
value that can be returned and the highest value that can be returned.
|
||||
|
||||
Defined types:
|
||||
verb(
|
||||
typedef IntType result_type;
|
||||
|
||||
struct param_type
|
||||
{
|
||||
explicit param_type(IntType a = 0, IntType b = max(IntType));
|
||||
|
||||
IntType a() const;
|
||||
IntType b() const;
|
||||
};
|
||||
)
|
||||
|
||||
Constructor, members and example:
|
||||
itemization(
|
||||
itt(uniform_int_distribution(IntType a = 0, IntType b = max(IntType)))
|
||||
constructs a uniform_int distribution for the specified range of
|
||||
values.
|
||||
itt(uniform_int_distribution(param_type const ¶m))
|
||||
constructs a uniform_int distribution according to the values stored in
|
||||
the tt(param) struct.
|
||||
itt(IntType a() const)nl()
|
||||
returns the distribution's tt(a) parameter;
|
||||
itt(IntType b() const)nl()
|
||||
returns the distribution's tt(b) parameter;
|
||||
itt(result_type min() const)nl()
|
||||
returns the distribution's tt(a) parameter;
|
||||
itt(result_type max() const)nl()
|
||||
returns the distribution's tt(b) parameter;
|
||||
it() Example:
|
||||
verbinclude(stl/examples/uniformint.cc)
|
||||
)
|
||||
|
||||
|
42
yo/stl/uniformreal.yo
Normal file
42
yo/stl/uniformreal.yo
Normal file
|
@ -0,0 +1,42 @@
|
|||
The ti(uniform_real_distribution<RealType = double>) can be used to select
|
||||
tt(RealType) values randomly from a range of uniformly distributed
|
||||
tt(RealType) values.
|
||||
|
||||
It has two parameters, tt(a) and tt(b), specifying, respectively, the
|
||||
half-open range of values (rangett(a, b)) that can be returned by the
|
||||
distribution.
|
||||
|
||||
Defined types:
|
||||
verb(
|
||||
typedef RealType result_type;
|
||||
|
||||
struct param_type
|
||||
{
|
||||
explicit param_type(RealType a = 0, RealType b = max(RealType));
|
||||
|
||||
RealType a() const;
|
||||
RealType b() const;
|
||||
};
|
||||
)
|
||||
|
||||
Constructor, members and example:
|
||||
itemization(
|
||||
itt(uniform_real_distribution(RealType a = 0, RealType b = max(RealType)))
|
||||
constructs a uniform_real distribution for the specified range of
|
||||
values.
|
||||
itt(uniform_real_distribution(param_type const ¶m))
|
||||
constructs a uniform_real distribution according to the values stored in
|
||||
the tt(param) struct.
|
||||
itt(RealType a() const)nl()
|
||||
returns the distribution's tt(a) parameter;
|
||||
itt(RealType b() const)nl()
|
||||
returns the distribution's tt(b) parameter;
|
||||
itt(result_type min() const)nl()
|
||||
returns the distribution's tt(a) parameter;
|
||||
itt(result_type max() const)nl()
|
||||
returns the distribution's tt(b) parameter;
|
||||
it() Example:
|
||||
verbinclude(stl/examples/uniformreal.cc)
|
||||
)
|
||||
|
||||
|
Loading…
Reference in a new issue