File: statistical.yo

package info (click to toggle)
c%2B%2B-annotations 10.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 10,536 kB
  • ctags: 3,247
  • sloc: cpp: 19,157; makefile: 1,521; ansic: 165; sh: 128; perl: 90
file content (68 lines) | stat: -rw-r--r-- 3,427 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
In the following sections the various statistical distributions that are
supported by bf(C++) 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):
    itemization(
    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 &param))
        redefines the parameters of the distribution;
    itt(void reset():)
       clears all of its cached values;
    )

    All distributions support 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 &param))nl() returns the next random value
        from the statistical distribution initialized 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,
            distribution-name const &bd):)
        The parameters of the distribution are inserted into an
        tt(std::ostream)
    )

    The following example shows how the distributions can be used. Replacing
the name of the distribution (tt(normal_distribution)) by another
distribution's name is all that is required to switch distributions. All
distributions have parameters, like the mean and standard deviation of the
normal distribution, and all parameters have default values. The names of the
parameters vary over distributions and are mentioned below at the individual
distributions. Distributions offer members returning or setting their
parameters.

Most distributions are defined as class templates, requiring the specification
of a data type that is used for the function's return type. If so, an empty
template parameter type specification (tt(<>)) will get you the default
type. The default types are either tt(double) (for real valued return types)
or tt(int) (for integral valued return types). The template parameter type
specification must be omitted with distributions that are not defined as
template classes.

Here is an example showing the use of the statistical distributions, applied
to the normal distribution:

        verbinclude(-a examples/normal.cc)