author | Peter D. Barnes, Jr. <barnes26@llnl.gov> |
Tue, 21 Jul 2015 16:20:17 -0700 | |
changeset 11531 | 5d6b3f94ebf3 |
parent 11046 | e62bccfbe56e |
child 11538 | 397bd6465dd9 |
permissions | -rw-r--r-- |
8871
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
2 |
/* |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
3 |
* Copyright (c) 2006 Georgia Tech Research Corporation |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
4 |
* Copyright (c) 2011 Mathieu Lacage |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
5 |
* |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
6 |
* This program is free software; you can redistribute it and/or modify |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
7 |
* it under the terms of the GNU General Public License version 2 as |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
8 |
* published by the Free Software Foundation; |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
9 |
* |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
10 |
* This program is distributed in the hope that it will be useful, |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
13 |
* GNU General Public License for more details. |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
14 |
* |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
16 |
* along with this program; if not, write to the Free Software |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
17 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
18 |
* |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
19 |
* Authors: Rajib Bhattacharjea<raj.b@gatech.edu> |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
20 |
* Hadi Arbabi<marbabi@cs.odu.edu> |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
21 |
* Mathieu Lacage <mathieu.lacage@gmail.com> |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
22 |
* |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
23 |
* Modified by Mitch Watrous <watrous@u.washington.edu> |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
24 |
* |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
25 |
*/ |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
26 |
#ifndef RANDOM_VARIABLE_STREAM_H |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
27 |
#define RANDOM_VARIABLE_STREAM_H |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
28 |
|
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
29 |
#include "type-id.h" |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
30 |
#include "object.h" |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
31 |
#include "attribute-helper.h" |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
32 |
#include <stdint.h> |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
33 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
34 |
/** |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
35 |
* \file |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
36 |
* \ingroup randomvariable |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
37 |
* Declaration of ns3::RandomVariableStream and derivatives. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
38 |
*/ |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
39 |
|
8871
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
40 |
namespace ns3 { |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
41 |
|
9970
a613974fffeb
[Doxygen] Organize Core/Random Variables
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9904
diff
changeset
|
42 |
/** |
a613974fffeb
[Doxygen] Organize Core/Random Variables
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9904
diff
changeset
|
43 |
* \ingroup core |
a613974fffeb
[Doxygen] Organize Core/Random Variables
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9904
diff
changeset
|
44 |
* \defgroup randomvariable Random Variables |
a613974fffeb
[Doxygen] Organize Core/Random Variables
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9904
diff
changeset
|
45 |
* |
a613974fffeb
[Doxygen] Organize Core/Random Variables
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9904
diff
changeset
|
46 |
* \brief ns-3 random numbers are provided via instances of |
a613974fffeb
[Doxygen] Organize Core/Random Variables
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9904
diff
changeset
|
47 |
* ns3::RandomVariableStream. |
a613974fffeb
[Doxygen] Organize Core/Random Variables
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9904
diff
changeset
|
48 |
* |
a613974fffeb
[Doxygen] Organize Core/Random Variables
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9904
diff
changeset
|
49 |
* - By default, ns-3 simulations use a fixed seed; if there is any |
a613974fffeb
[Doxygen] Organize Core/Random Variables
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9904
diff
changeset
|
50 |
* randomness in the simulation, each run of the program will yield |
a613974fffeb
[Doxygen] Organize Core/Random Variables
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9904
diff
changeset
|
51 |
* identical results unless the seed and/or run number is changed. |
a613974fffeb
[Doxygen] Organize Core/Random Variables
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9904
diff
changeset
|
52 |
* - In ns-3.3 and earlier, ns-3 simulations used a random seed by default; |
a613974fffeb
[Doxygen] Organize Core/Random Variables
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9904
diff
changeset
|
53 |
* this marks a change in policy starting with ns-3.4. |
a613974fffeb
[Doxygen] Organize Core/Random Variables
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9904
diff
changeset
|
54 |
* - In ns-3.14 and earlier, ns-3 simulations used a different wrapper |
a613974fffeb
[Doxygen] Organize Core/Random Variables
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9904
diff
changeset
|
55 |
* class called ns3::RandomVariable. This implementation is documented |
a613974fffeb
[Doxygen] Organize Core/Random Variables
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9904
diff
changeset
|
56 |
* above under Legacy Random Variables. As of ns-3.15, this class has |
a613974fffeb
[Doxygen] Organize Core/Random Variables
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9904
diff
changeset
|
57 |
* been replaced by ns3::RandomVariableStream; the underlying |
a613974fffeb
[Doxygen] Organize Core/Random Variables
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9904
diff
changeset
|
58 |
* pseudo-random number generator has not changed. |
a613974fffeb
[Doxygen] Organize Core/Random Variables
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9904
diff
changeset
|
59 |
* - To obtain randomness across multiple simulation runs, you must |
a613974fffeb
[Doxygen] Organize Core/Random Variables
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9904
diff
changeset
|
60 |
* either set the seed differently or set the run number differently. |
a613974fffeb
[Doxygen] Organize Core/Random Variables
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9904
diff
changeset
|
61 |
* To set a seed, call ns3::RngSeedManager::SetSeed() at the beginning |
a613974fffeb
[Doxygen] Organize Core/Random Variables
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9904
diff
changeset
|
62 |
* of the program; to set a run number with the same seed, call |
a613974fffeb
[Doxygen] Organize Core/Random Variables
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9904
diff
changeset
|
63 |
* ns3::RngSeedManager::SetRun() at the beginning of the program. |
a613974fffeb
[Doxygen] Organize Core/Random Variables
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9904
diff
changeset
|
64 |
* - Each RandomVariableStream used in ns-3 has a virtual random number |
a613974fffeb
[Doxygen] Organize Core/Random Variables
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9904
diff
changeset
|
65 |
* generator associated with it; all random variables use either |
a613974fffeb
[Doxygen] Organize Core/Random Variables
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9904
diff
changeset
|
66 |
* a fixed or random seed based on the use of the global seed. |
a613974fffeb
[Doxygen] Organize Core/Random Variables
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9904
diff
changeset
|
67 |
* - If you intend to perform multiple runs of the same scenario, |
a613974fffeb
[Doxygen] Organize Core/Random Variables
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9904
diff
changeset
|
68 |
* with different random numbers, please be sure to read the manual |
a613974fffeb
[Doxygen] Organize Core/Random Variables
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9904
diff
changeset
|
69 |
* section on how to perform independent replications. |
a613974fffeb
[Doxygen] Organize Core/Random Variables
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9904
diff
changeset
|
70 |
*/ |
a613974fffeb
[Doxygen] Organize Core/Random Variables
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9904
diff
changeset
|
71 |
|
8871
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
72 |
class RngStream; |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
73 |
|
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
74 |
/** |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
75 |
* \ingroup randomvariable |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
76 |
* \brief The basic uniform Random Number Generator (RNG). |
8871
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
77 |
* |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
78 |
* \note The underlying random number generation method used |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
79 |
* by ns-3 is the RngStream code by Pierre L'Ecuyer at |
8871
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
80 |
* the University of Montreal. |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
81 |
* |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
82 |
* ns-3 has a rich set of random number generators that allow stream |
8871
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
83 |
* numbers to be set deterministically if desired. Class |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
84 |
* RandomVariableStream defines the base class functionalty required |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
85 |
* for all such random number generators. |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
86 |
* |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
87 |
* By default, the underlying generator is seeded all the time with |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
88 |
* the same seed value and run number coming from the ns3::GlobalValue |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
89 |
* \ref GlobalValueRngSeed "RngSeed" and \ref GlobalValueRngRun |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
90 |
* "RngRun". Also by default, the stream number value for this RNG |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
91 |
* stream is automatically allocated. |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
92 |
* |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
93 |
* Instances can be configured to return "antithetic" values. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
94 |
* See the documentation for the specific distributions to see |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
95 |
* how this modifies the returned values. |
8871
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
96 |
*/ |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
97 |
class RandomVariableStream : public Object |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
98 |
{ |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
99 |
public: |
11046
e62bccfbe56e
[Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10218
diff
changeset
|
100 |
/** |
e62bccfbe56e
[Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10218
diff
changeset
|
101 |
* \brief Register this type. |
e62bccfbe56e
[Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10218
diff
changeset
|
102 |
* \return The object TypeId. |
e62bccfbe56e
[Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10218
diff
changeset
|
103 |
*/ |
8871
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
104 |
static TypeId GetTypeId (void); |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
105 |
/** |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
106 |
* \brief Default constructor. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
107 |
*/ |
8871
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
108 |
RandomVariableStream (); |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
109 |
/** |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
110 |
* \brief Destructor. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
111 |
*/ |
8871
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
112 |
virtual ~RandomVariableStream(); |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
113 |
|
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
114 |
/** |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
115 |
* \brief Specifies the stream number for this RNG stream. |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
116 |
* \param stream The stream number for this RNG stream. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
117 |
* -1 means "allocate a stream number automatically". |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
118 |
*/ |
8871
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
119 |
void SetStream (int64_t stream); |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
120 |
|
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
121 |
/** |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
122 |
* \brief Returns the stream number for this RNG stream. |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
123 |
* \return The stream number for this RNG stream. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
124 |
* -1 means this stream was allocated automatically. |
8871
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
125 |
*/ |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
126 |
int64_t GetStream(void) const; |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
127 |
|
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
128 |
/** |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
129 |
* \brief Specify whether antithetic values should be generated. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
130 |
* \param isAntithetic If \c true antithetic value will be generated. |
8871
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
131 |
*/ |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
132 |
void SetAntithetic(bool isAntithetic); |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
133 |
|
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
134 |
/** |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
135 |
* \brief Check if antithetic values will be generated. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
136 |
* \return \c true if antithetic values will be generated. |
8871
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
137 |
*/ |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
138 |
bool IsAntithetic(void) const; |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
139 |
|
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
140 |
/** |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
141 |
* \brief Get the next random value as a double drawn from the distribution. |
8871
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
142 |
* \return A floating point random value. |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
143 |
*/ |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
144 |
virtual double GetValue (void) = 0; |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
145 |
|
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
146 |
/** |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
147 |
* \brief Get the next random value as an integer drawn from the distribution. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
148 |
* \return An integer random value. |
8871
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
149 |
*/ |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
150 |
virtual uint32_t GetInteger (void) = 0; |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
151 |
|
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
152 |
protected: |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
153 |
/** |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
154 |
* \brief Get the pointer to the underlying RNG stream. |
8871
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
155 |
*/ |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
156 |
RngStream *Peek(void) const; |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
157 |
|
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
158 |
private: |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
159 |
/** |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
160 |
* Copy constructor. These objects are not copyable. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
161 |
* |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
162 |
* \param o The RandomVariableStream to copy in construction. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
163 |
* \internal |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
164 |
* Theoretically, it is possible to give them good copy semantics |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
165 |
* but not enough time to iron out the details. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
166 |
*/ |
8871
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
167 |
RandomVariableStream (const RandomVariableStream &o); |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
168 |
/** |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
169 |
* Assignment operator. These objects can't be copied by assignement. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
170 |
* |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
171 |
* \param o The RandomVariableStream to copy. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
172 |
* \return lvalue RandomVariableStream. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
173 |
* |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
174 |
* \internal |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
175 |
* Theoretically, it is possible to give them good copy semantics |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
176 |
* but not enough time to iron out the details. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
177 |
*/ |
8871
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
178 |
RandomVariableStream &operator = (const RandomVariableStream &o); |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
179 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
180 |
/** Pointer to the underlying RNG stream. */ |
8871
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
181 |
RngStream *m_rng; |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
182 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
183 |
/** Indicates if antithetic values should be generated by this RNG stream. */ |
8871
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
184 |
bool m_isAntithetic; |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
185 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
186 |
/** The stream number for this RNG stream. */ |
8871
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
187 |
int64_t m_stream; |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
188 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
189 |
}; // class RandomVariableStream |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
190 |
|
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
191 |
|
8871
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
192 |
/** |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
193 |
* \ingroup randomvariable |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
194 |
* \brief The uniform distribution Random Number Generator (RNG). |
8871
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
195 |
* |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
196 |
* This class supports the creation of objects that return random numbers |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
197 |
* from a fixed uniform distribution. It also supports the generation of |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
198 |
* single random numbers from various uniform distributions. |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
199 |
* |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
200 |
* The output range is \f$[min, max)\f$ for floating point values, |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
201 |
* (\c max <i>excluded</i>), and \f$[min, max]\f$ (\c max <i>included</i>) |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
202 |
* for integral values. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
203 |
* |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
204 |
* \par Example |
8871
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
205 |
* |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
206 |
* Here is an example of how to use this class: |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
207 |
* \code |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
208 |
* double min = 0.0; |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
209 |
* double max = 10.0; |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
210 |
* |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
211 |
* Ptr<UniformRandomVariable> x = CreateObject<UniformRandomVariable> (); |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
212 |
* x->SetAttribute ("Min", DoubleValue (min)); |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
213 |
* x->SetAttribute ("Max", DoubleValue (max)); |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
214 |
* |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
215 |
* // The values returned by a uniformly distributed random |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
216 |
* // variable should always be within the range |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
217 |
* // |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
218 |
* // [min, max) . |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
219 |
* // |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
220 |
* double value = x->GetValue (); |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
221 |
* \endcode |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
222 |
* |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
223 |
* \par Antithetic Values. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
224 |
* |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
225 |
* Normally this RNG returns values \f$x\f$ in the interval \f$[min,max)\f$. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
226 |
* If an instance of this RNG is configured to return antithetic values, |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
227 |
* the actual value returned is calculated as follows: |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
228 |
* |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
229 |
* - Compute the initial random value \f$x\f$ as normal. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
230 |
* - Compute the distance from the maximum, \f$y = max - x\f$ |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
231 |
* - Return \f$x' = min + y = min + (max - x)\f$: |
8871
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
232 |
*/ |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
233 |
class UniformRandomVariable : public RandomVariableStream |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
234 |
{ |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
235 |
public: |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
236 |
/** |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
237 |
* \brief Register this type. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
238 |
* \return The object TypeId. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
239 |
*/ |
8871
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
240 |
static TypeId GetTypeId (void); |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
241 |
|
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
242 |
/** |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
243 |
* \brief Creates a uniform distribution RNG with the default range. |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
244 |
*/ |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
245 |
UniformRandomVariable (); |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
246 |
|
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
247 |
/** |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
248 |
* \brief Get the lower bound on randoms returned by GetValue(void). |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
249 |
* \return The lower bound on values from GetValue(void). |
8871
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
250 |
*/ |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
251 |
double GetMin (void) const; |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
252 |
|
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
253 |
/** |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
254 |
* \brief Get the upper bound on values returned by GetValue(void). |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
255 |
* \return The upper bound on values from GetValue(void). |
8871
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
256 |
*/ |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
257 |
double GetMax (void) const; |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
258 |
|
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
259 |
/** |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
260 |
* \brief Get the next random value, as a double in the specified range |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
261 |
* \f$[min, max)\f$. |
8871
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
262 |
* |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
263 |
* \note The upper limit is excluded from the output range. |
8871
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
264 |
* |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
265 |
* \param min Low end of the range (included). |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
266 |
* \param max High end of the range (excluded). |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
267 |
* \return A floating point random value. |
8871
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
268 |
*/ |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
269 |
double GetValue (double min, double max); |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
270 |
|
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
271 |
/** |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
272 |
* \brief Get the next random value, as an unsigned integer in the |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
273 |
* specified range \f$[min, max]/f$. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
274 |
* |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
275 |
* \note The upper limit is included in the output range. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
276 |
* |
8871
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
277 |
* \param min Low end of the range. |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
278 |
* \param max High end of the range. |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
279 |
* \return A random unsigned integer value. |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
280 |
*/ |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
281 |
uint32_t GetInteger (uint32_t min, uint32_t max); |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
282 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
283 |
// Inherited from RandomVariableStream |
8871
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
284 |
/** |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
285 |
* \brief Get the next random value as a double drawn from the distribution. |
8871
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
286 |
* \return A floating point random value. |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
287 |
* \note The upper limit is excluded from the output range. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
288 |
*/ |
8871
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
289 |
virtual double GetValue (void); |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
290 |
/** |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
291 |
* \brief Get the next random value as an integer drawn from the distribution. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
292 |
* \return An integer random value. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
293 |
* \note The upper limit is included in the output range. |
8871
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
294 |
*/ |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
295 |
virtual uint32_t GetInteger (void); |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
296 |
|
8871
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
297 |
private: |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
298 |
/** The lower bound on values that can be returned by this RNG stream. */ |
8871
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
299 |
double m_min; |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
300 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
301 |
/** The upper bound on values that can be returned by this RNG stream. */ |
8871
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
302 |
double m_max; |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
303 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
304 |
}; // class UniformRandomVariable |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
305 |
|
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
306 |
|
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
307 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
308 |
* \ingroup randomvariable |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
309 |
* \brief The Random Number Generator (RNG) that returns a constant. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
310 |
* |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
311 |
* This RNG returns the same value for every sample. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
312 |
* |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
313 |
* \par Antithetic Values. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
314 |
* |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
315 |
* This RNG ignores the antithetic setting. |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
316 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
317 |
class ConstantRandomVariable : public RandomVariableStream |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
318 |
{ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
319 |
public: |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
320 |
/** |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
321 |
* \brief Register this type. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
322 |
* \return The object TypeId. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
323 |
*/ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
324 |
static TypeId GetTypeId (void); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
325 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
326 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
327 |
* \brief Creates a constant RNG with the default constant value. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
328 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
329 |
ConstantRandomVariable (); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
330 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
331 |
/** |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
332 |
* \brief Get the constant value returned by this RNG stream. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
333 |
* \return The constant value. |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
334 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
335 |
double GetConstant (void) const; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
336 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
337 |
/** |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
338 |
* \brief Get the next random value, as a double equal to the argument. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
339 |
* \param constant The value to return. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
340 |
* \return The floating point argument. |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
341 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
342 |
double GetValue (double constant); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
343 |
/** |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
344 |
* \brief Get the next random value, as an integer equal to the argument. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
345 |
* \param constant The value to return. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
346 |
* \return The integer argument. |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
347 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
348 |
uint32_t GetInteger (uint32_t constant); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
349 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
350 |
// Inherited from RandomVariableStream |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
351 |
/* \note This RNG always returns the same value. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
352 |
virtual double GetValue (void); |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
353 |
/* \note This RNG always returns the same value. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
354 |
virtual uint32_t GetInteger (void); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
355 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
356 |
private: |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
357 |
/** The constant value returned by this RNG stream. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
358 |
double m_constant; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
359 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
360 |
}; // class ConstantRandomVariable |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
361 |
|
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
362 |
|
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
363 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
364 |
* \ingroup randomvariable |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
365 |
* \brief The Random Number Generator (RNG) that returns a pattern of |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
366 |
* sequential values. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
367 |
* |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
368 |
* This RNG has four configuration attributes: |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
369 |
* |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
370 |
* - An increment, \c Increment. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
371 |
* - A consecutive repeat numer, \c Consecutive. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
372 |
* - The minimum value, \c Min. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
373 |
* - The maximum value, \c Max. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
374 |
* |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
375 |
* The RNG starts at the \c Min value. Each return value is |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
376 |
* repeated \c Consecutive times, before advancing by the \c Increment. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
377 |
* When the \c Increment would cause the value to equal or exceed |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
378 |
* \c Max it is reset to \c Min first. |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
379 |
* |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
380 |
* For example, if an instance is configured with: |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
381 |
* |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
382 |
* Attribute | Value |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
383 |
* :---------- | -----: |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
384 |
* Min | 2 |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
385 |
* Max | 13 |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
386 |
* Increment | 4 |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
387 |
* Consecutive | 3 |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
388 |
* |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
389 |
* The sequence will repeat this pattern: 2 2 2 6 6 6 10 10 10. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
390 |
* |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
391 |
* Notice that \c Max will be a strict upper bound on the values: |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
392 |
* all values in the sequence will be less than \c Max. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
393 |
* |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
394 |
* \par Antithetic Values. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
395 |
* |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
396 |
* This RNG ignores the antithetic setting. |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
397 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
398 |
class SequentialRandomVariable : public RandomVariableStream |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
399 |
{ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
400 |
public: |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
401 |
/** |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
402 |
* \brief Register this type. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
403 |
* \return The object TypeId. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
404 |
*/ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
405 |
static TypeId GetTypeId (void); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
406 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
407 |
/** |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
408 |
* \brief Creates a sequential RNG with the default values |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
409 |
* for the sequence parameters. |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
410 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
411 |
SequentialRandomVariable (); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
412 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
413 |
/** |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
414 |
* \brief Get the first value of the sequence. |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
415 |
* \return The first value of the sequence. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
416 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
417 |
double GetMin (void) const; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
418 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
419 |
/** |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
420 |
* \brief Get the limit of the sequence, which is (at least) |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
421 |
* one more than the last value of the sequence. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
422 |
* \return The limit of the sequence. |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
423 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
424 |
double GetMax (void) const; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
425 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
426 |
/** |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
427 |
* \brief Get the increment for the sequence. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
428 |
* \return The increment between distinct values for the sequence. |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
429 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
430 |
Ptr<RandomVariableStream> GetIncrement (void) const; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
431 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
432 |
/** |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
433 |
* \brief Get the number of times each distinct value of the sequence |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
434 |
* is repeated before incrementing to the next value. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
435 |
* \return The number of times each value is repeated. |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
436 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
437 |
uint32_t GetConsecutive (void) const; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
438 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
439 |
// Inherited from RandomVariableStream |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
440 |
virtual double GetValue (void); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
441 |
virtual uint32_t GetInteger (void); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
442 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
443 |
private: |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
444 |
/** The first value of the sequence. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
445 |
double m_min; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
446 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
447 |
/** Strict upper bound on the sequence. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
448 |
double m_max; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
449 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
450 |
/** Increment between distinct values. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
451 |
Ptr<RandomVariableStream> m_increment; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
452 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
453 |
/** The number of times each distinct value is repeated. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
454 |
uint32_t m_consecutive; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
455 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
456 |
/** The current sequence value. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
457 |
double m_current; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
458 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
459 |
/** The number of times the current distinct value has been repeated. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
460 |
uint32_t m_currentConsecutive; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
461 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
462 |
/** Indicates if the current sequence value has been properly initialized. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
463 |
bool m_isCurrentSet; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
464 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
465 |
}; // class SequentialRandomVariable |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
466 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
467 |
|
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
468 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
469 |
* \ingroup randomvariable |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
470 |
* \brief The exponential distribution Random Number Generator (RNG). |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
471 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
472 |
* This class supports the creation of objects that return random numbers |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
473 |
* from a fixed exponential distribution. It also supports the generation of |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
474 |
* single random numbers from various exponential distributions. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
475 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
476 |
* The probability density function of an exponential variable |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
477 |
* is defined as: |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
478 |
* \f[ |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
479 |
* P(x) dx = \alpha e^{-\alpha x} dx, \quad x \in [0, +\infty) |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
480 |
* \f] |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
481 |
* over the interval \f$[0, +\infty)\f$, where \f$ \alpha = \frac{1}{Mean} \f$ |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
482 |
* and \c Mean is a configurable attribute. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
483 |
* |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
484 |
* The normal RNG value \f$x\f$ is calculated by |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
485 |
* |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
486 |
* \f[ |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
487 |
* x = - 1/\alpha \log(u) |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
488 |
* \f] |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
489 |
* |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
490 |
* where \f$u\f$ is a uniform random variable on \f$[0,1)\f$. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
491 |
* |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
492 |
* \par Bounded Distribution |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
493 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
494 |
* Since exponential distributions can theoretically return unbounded |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
495 |
* values, it is sometimes useful to specify a fixed upper limit. The |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
496 |
* bounded version is defined over the interval \f$[0,b]\f$ as: |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
497 |
* |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
498 |
* \f[ |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
499 |
* P(x; b) dx = \alpha e^{-\alpha x} dx \quad x \in [0,b] |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
500 |
* \f] |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
501 |
* |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
502 |
* where the \c Bound \f$b\f$ is a configurable attribute. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
503 |
* |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
504 |
* Note that in this case the true mean of the distribution is smaller |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
505 |
* than the nominal mean value: |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
506 |
* |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
507 |
* \f[ |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
508 |
* <X: P(x; b)> = 1/\alpha - b/(e^{\alpha \, b} -1) |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
509 |
* \f] |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
510 |
* |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
511 |
* \par Example |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
512 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
513 |
* Here is an example of how to use this class: |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
514 |
* \code |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
515 |
* double mean = 3.14; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
516 |
* double bound = 0.0; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
517 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
518 |
* Ptr<ExponentialRandomVariable> x = CreateObject<ExponentialRandomVariable> (); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
519 |
* x->SetAttribute ("Mean", DoubleValue (mean)); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
520 |
* x->SetAttribute ("Bound", DoubleValue (bound)); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
521 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
522 |
* // The expected value for the mean of the values returned by an |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
523 |
* // exponentially distributed random variable is equal to mean. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
524 |
* double value = x->GetValue (); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
525 |
* \endcode |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
526 |
* |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
527 |
* \par Antithetic Values. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
528 |
* |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
529 |
* The antithetic value is calculated from |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
530 |
* |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
531 |
* \f[ |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
532 |
* x' = - mean * \log(1 - u), |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
533 |
* \f] |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
534 |
* |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
535 |
* where again \f$u\f$ is a uniform random variable on \f$[0,1)\f$. |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
536 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
537 |
class ExponentialRandomVariable : public RandomVariableStream |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
538 |
{ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
539 |
public: |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
540 |
/** |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
541 |
* \brief Register this type. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
542 |
* \return The object TypeId. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
543 |
*/ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
544 |
static TypeId GetTypeId (void); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
545 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
546 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
547 |
* \brief Creates a exponential distribution RNG with the default |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
548 |
* values for the mean and upper bound. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
549 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
550 |
ExponentialRandomVariable (); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
551 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
552 |
/** |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
553 |
* \brief Get the configured mean value of this RNG. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
554 |
* |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
555 |
* \note This will not be the actual mean if the distribution is |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
556 |
* truncated by a bound. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
557 |
* \return The configured mean value. |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
558 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
559 |
double GetMean (void) const; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
560 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
561 |
/** |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
562 |
* \brief Get the configured upper bound of this RNG. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
563 |
* \return The upper bound. |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
564 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
565 |
double GetBound (void) const; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
566 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
567 |
/** |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
568 |
* \brief Get the next random value, as a double from |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
569 |
* the exponential distribution with the specified mean and upper bound. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
570 |
* \param mean Mean value of the unbounded exponential distribution. |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
571 |
* \param bound Upper bound on values returned. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
572 |
* \return A floating point random value. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
573 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
574 |
double GetValue (double mean, double bound); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
575 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
576 |
/** |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
577 |
* \brief Get the next random value, as an unsigned integer from |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
578 |
* the exponential distribution with the specified mean and upper bound. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
579 |
* \param mean Mean value of the unbounded exponential distributuion. |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
580 |
* \param bound Upper bound on values returned. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
581 |
* \return A random unsigned integer value. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
582 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
583 |
uint32_t GetInteger (uint32_t mean, uint32_t bound); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
584 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
585 |
// Inherited from RandomVariableStream |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
586 |
virtual double GetValue (void); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
587 |
virtual uint32_t GetInteger (void); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
588 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
589 |
private: |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
590 |
/** The mean value of the unbounded exponential distribution. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
591 |
double m_mean; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
592 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
593 |
/** The upper bound on values that can be returned by this RNG stream. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
594 |
double m_bound; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
595 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
596 |
}; // class ExponentialRandomVariable |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
597 |
|
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
598 |
|
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
599 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
600 |
* \ingroup randomvariable |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
601 |
* \brief The Pareto distribution Random Number Generator (RNG). |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
602 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
603 |
* This class supports the creation of objects that return random numbers |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
604 |
* from a fixed Pareto distribution. It also supports the generation of |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
605 |
* single random numbers from various Pareto distributions. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
606 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
607 |
* The probability density function of a Pareto variable is defined |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
608 |
* over the range [\f$x_m\f$,\f$+\infty\f$) as: \f$ k \frac{x_m^k}{x^{k+1}}\f$ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
609 |
* where \f$x_m > 0\f$ is called the scale parameter and \f$ k > 0\f$ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
610 |
* is called the pareto index or shape. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
611 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
612 |
* The parameter \f$ x_m \f$ can be infered from the mean and the parameter \f$ k \f$ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
613 |
* with the equation \f$ x_m = mean \frac{k-1}{k}, k > 1\f$. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
614 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
615 |
* Since Pareto distributions can theoretically return unbounded values, |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
616 |
* it is sometimes useful to specify a fixed upper limit. Note however |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
617 |
* when the upper limit is specified, the true mean of the distribution |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
618 |
* is slightly smaller than the mean value specified. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
619 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
620 |
* Here is an example of how to use this class: |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
621 |
* \code |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
622 |
* double mean = 5.0; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
623 |
* double shape = 2.0; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
624 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
625 |
* Ptr<ParetoRandomVariable> x = CreateObject<ParetoRandomVariable> (); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
626 |
* x->SetAttribute ("Mean", DoubleValue (mean)); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
627 |
* x->SetAttribute ("Shape", DoubleValue (shape)); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
628 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
629 |
* // The expected value for the mean of the values returned by a |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
630 |
* // Pareto distributed random variable is |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
631 |
* // |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
632 |
* // shape * scale |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
633 |
* // E[value] = --------------- , |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
634 |
* // shape - 1 |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
635 |
* // |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
636 |
* // where |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
637 |
* // |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
638 |
* // scale = mean * (shape - 1.0) / shape . |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
639 |
* // |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
640 |
* double value = x->GetValue (); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
641 |
* \endcode |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
642 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
643 |
class ParetoRandomVariable : public RandomVariableStream |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
644 |
{ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
645 |
public: |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
646 |
/** |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
647 |
* \brief Register this type. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
648 |
* \return The object TypeId. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
649 |
*/ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
650 |
static TypeId GetTypeId (void); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
651 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
652 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
653 |
* \brief Creates a Pareto distribution RNG with the default |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
654 |
* values for the mean, the shape, and upper bound. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
655 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
656 |
ParetoRandomVariable (); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
657 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
658 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
659 |
* \brief Returns the mean parameter for the Pareto distribution returned by this RNG stream. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
660 |
* \return The mean parameter for the Pareto distribution returned by this RNG stream. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
661 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
662 |
double GetMean (void) const; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
663 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
664 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
665 |
* \brief Returns the shape parameter for the Pareto distribution returned by this RNG stream. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
666 |
* \return The shape parameter for the Pareto distribution returned by this RNG stream. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
667 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
668 |
double GetShape (void) const; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
669 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
670 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
671 |
* \brief Returns the upper bound on values that can be returned by this RNG stream. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
672 |
* \return The upper bound on values that can be returned by this RNG stream. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
673 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
674 |
double GetBound (void) const; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
675 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
676 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
677 |
* \brief Returns a random double from a Pareto distribution with the specified mean, shape, and upper bound. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
678 |
* \param mean Mean parameter for the Pareto distribution. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
679 |
* \param shape Shape parameter for the Pareto distribution. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
680 |
* \param bound Upper bound on values returned. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
681 |
* \return A floating point random value. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
682 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
683 |
* Note that antithetic values are being generated if |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
684 |
* m_isAntithetic is equal to true. If \f$u\f$ is a uniform variable |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
685 |
* over [0,1] and |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
686 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
687 |
* \f[ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
688 |
* x = \frac{scale}{u^{\frac{1}{shape}}} |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
689 |
* \f] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
690 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
691 |
* is a value that would be returned normally, where |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
692 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
693 |
* \f[ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
694 |
* scale = mean * (shape - 1.0) / shape . |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
695 |
* \f] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
696 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
697 |
* Then \f$(1 - u\f$) is the distance that \f$u\f$ would be from |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
698 |
* \f$1\f$. The value returned in the antithetic case, \f$x'\f$, is |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
699 |
* calculated as |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
700 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
701 |
* \f[ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
702 |
* x' = \frac{scale}{{(1 - u)}^{\frac{1}{shape}}} , |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
703 |
* \f] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
704 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
705 |
* which now involves the distance \f$u\f$ is from 1 in the denonator. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
706 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
707 |
double GetValue (double mean, double shape, double bound); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
708 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
709 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
710 |
* \brief Returns a random unsigned integer from a Pareto distribution with the specified mean, shape, and upper bound. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
711 |
* \param mean Mean parameter for the Pareto distribution. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
712 |
* \param shape Shape parameter for the Pareto distribution. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
713 |
* \param bound Upper bound on values returned. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
714 |
* \return A random unsigned integer value. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
715 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
716 |
* Note that antithetic values are being generated if |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
717 |
* m_isAntithetic is equal to true. If \f$u\f$ is a uniform variable |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
718 |
* over [0,1] and |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
719 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
720 |
* \f[ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
721 |
* x = \frac{scale}{u^{\frac{1}{shape}}} |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
722 |
* \f] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
723 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
724 |
* is a value that would be returned normally, where |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
725 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
726 |
* \f[ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
727 |
* scale = mean * (shape - 1.0) / shape . |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
728 |
* \f] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
729 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
730 |
* Then \f$(1 - u\f$) is the distance that \f$u\f$ would be from |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
731 |
* \f$1\f$. The value returned in the antithetic case, \f$x'\f$, is |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
732 |
* calculated as |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
733 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
734 |
* \f[ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
735 |
* x' = \frac{scale}{{(1 - u)}^{\frac{1}{shape}}} , |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
736 |
* \f] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
737 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
738 |
* which now involves the distance \f$u\f$ is from 1 in the denonator. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
739 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
740 |
uint32_t GetInteger (uint32_t mean, uint32_t shape, uint32_t bound); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
741 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
742 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
743 |
* \brief Returns a random double from a Pareto distribution with the current mean, shape, and upper bound. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
744 |
* \return A floating point random value. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
745 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
746 |
* Note that antithetic values are being generated if |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
747 |
* m_isAntithetic is equal to true. If \f$u\f$ is a uniform variable |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
748 |
* over [0,1] and |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
749 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
750 |
* \f[ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
751 |
* x = \frac{scale}{u^{\frac{1}{shape}}} |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
752 |
* \f] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
753 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
754 |
* is a value that would be returned normally, where |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
755 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
756 |
* \f[ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
757 |
* scale = mean * (shape - 1.0) / shape . |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
758 |
* \f] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
759 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
760 |
* Then \f$(1 - u\f$) is the distance that \f$u\f$ would be from |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
761 |
* \f$1\f$. The value returned in the antithetic case, \f$x'\f$, is |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
762 |
* calculated as |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
763 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
764 |
* \f[ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
765 |
* x' = \frac{scale}{{(1 - u)}^{\frac{1}{shape}}} , |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
766 |
* \f] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
767 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
768 |
* which now involves the distance \f$u\f$ is from 1 in the denonator. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
769 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
770 |
* Note that we have to re-implement this method here because the method is |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
771 |
* overloaded above for the three-argument variant and the c++ name resolution |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
772 |
* rules don't work well with overloads split between parent and child |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
773 |
* classes. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
774 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
775 |
virtual double GetValue (void); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
776 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
777 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
778 |
* \brief Returns a random unsigned integer from a Pareto distribution with the current mean, shape, and upper bound. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
779 |
* \return A random unsigned integer value. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
780 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
781 |
* Note that antithetic values are being generated if |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
782 |
* m_isAntithetic is equal to true. If \f$u\f$ is a uniform variable |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
783 |
* over [0,1] and |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
784 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
785 |
* \f[ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
786 |
* x = \frac{scale}{u^{\frac{1}{shape}}} |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
787 |
* \f] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
788 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
789 |
* is a value that would be returned normally, where |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
790 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
791 |
* \f[ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
792 |
* scale = mean * (shape - 1.0) / shape . |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
793 |
* \f] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
794 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
795 |
* Then \f$(1 - u\f$) is the distance that \f$u\f$ would be from |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
796 |
* \f$1\f$. The value returned in the antithetic case, \f$x'\f$, is |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
797 |
* calculated as |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
798 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
799 |
* \f[ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
800 |
* x' = \frac{scale}{{(1 - u)}^{\frac{1}{shape}}} , |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
801 |
* \f] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
802 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
803 |
* which now involves the distance \f$u\f$ is from 1 in the denonator. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
804 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
805 |
virtual uint32_t GetInteger (void); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
806 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
807 |
private: |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
808 |
/** The mean parameter for the Pareto distribution returned by this RNG stream. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
809 |
double m_mean; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
810 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
811 |
/** The shape parameter for the Pareto distribution returned by this RNG stream. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
812 |
double m_shape; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
813 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
814 |
/** The upper bound on values that can be returned by this RNG stream. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
815 |
double m_bound; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
816 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
817 |
}; // class ParetoRandomVariable |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
818 |
|
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
819 |
|
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
820 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
821 |
* \ingroup randomvariable |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
822 |
* \brief The Weibull distribution Random Number Generator (RNG) that allows stream numbers to be set deterministically. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
823 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
824 |
* This class supports the creation of objects that return random numbers |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
825 |
* from a fixed Weibull distribution. It also supports the generation of |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
826 |
* single random numbers from various Weibull distributions. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
827 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
828 |
* The probability density function is defined over the interval [0, \f$+\infty\f$] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
829 |
* as: \f$ \frac{k}{\lambda}\left(\frac{x}{\lambda}\right)^{k-1}e^{-\left(\frac{x}{\lambda}\right)^k} \f$ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
830 |
* where \f$ k > 0\f$ is the shape parameter and \f$ \lambda > 0\f$ is the scale parameter. The |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
831 |
* specified mean is related to the scale and shape parameters by the following relation: |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
832 |
* \f$ mean = \lambda\Gamma\left(1+\frac{1}{k}\right) \f$ where \f$ \Gamma \f$ is the Gamma function. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
833 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
834 |
* Since Weibull distributions can theoretically return unbounded values, |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
835 |
* it is sometimes useful to specify a fixed upper limit. Note however |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
836 |
* when the upper limit is specified, the true mean of the distribution |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
837 |
* is slightly smaller than the mean value specified. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
838 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
839 |
* Here is an example of how to use this class: |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
840 |
* \code |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
841 |
* double scale = 5.0; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
842 |
* double shape = 1.0; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
843 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
844 |
* Ptr<WeibullRandomVariable> x = CreateObject<WeibullRandomVariable> (); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
845 |
* x->SetAttribute ("Scale", DoubleValue (scale)); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
846 |
* x->SetAttribute ("Shape", DoubleValue (shape)); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
847 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
848 |
* // The expected value for the mean of the values returned by a |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
849 |
* // Weibull distributed random variable is |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
850 |
* // |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
851 |
* // E[value] = scale * Gamma(1 + 1 / shape) , |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
852 |
* // |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
853 |
* // where Gamma() is the Gamma function. Note that |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
854 |
* // |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
855 |
* // Gamma(n) = (n - 1)! |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
856 |
* // |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
857 |
* // if n is a positive integer. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
858 |
* // |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
859 |
* // For this example, |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
860 |
* // |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
861 |
* // Gamma(1 + 1 / shape) = Gamma(1 + 1 / 1) |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
862 |
* // = Gamma(2) |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
863 |
* // = (2 - 1)! |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
864 |
* // = 1 |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
865 |
* // |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
866 |
* // which means |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
867 |
* // |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
868 |
* // E[value] = scale . |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
869 |
* // |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
870 |
* double value = x->GetValue (); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
871 |
* \endcode |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
872 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
873 |
class WeibullRandomVariable : public RandomVariableStream |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
874 |
{ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
875 |
public: |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
876 |
/** |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
877 |
* \brief Register this type. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
878 |
* \return The object TypeId. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
879 |
*/ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
880 |
static TypeId GetTypeId (void); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
881 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
882 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
883 |
* \brief Creates a Weibull distribution RNG with the default |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
884 |
* values for the scale, shape, and upper bound. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
885 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
886 |
WeibullRandomVariable (); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
887 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
888 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
889 |
* \brief Returns the scale parameter for the Weibull distribution returned by this RNG stream. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
890 |
* \return The scale parameter for the Weibull distribution returned by this RNG stream. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
891 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
892 |
double GetScale (void) const; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
893 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
894 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
895 |
* \brief Returns the shape parameter for the Weibull distribution returned by this RNG stream. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
896 |
* \return The shape parameter for the Weibull distribution returned by this RNG stream. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
897 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
898 |
double GetShape (void) const; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
899 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
900 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
901 |
* \brief Returns the upper bound on values that can be returned by this RNG stream. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
902 |
* \return The upper bound on values that can be returned by this RNG stream. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
903 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
904 |
double GetBound (void) const; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
905 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
906 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
907 |
* \brief Returns a random double from a Weibull distribution with the specified scale, shape, and upper bound. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
908 |
* \param scale Scale parameter for the Weibull distribution. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
909 |
* \param shape Shape parameter for the Weibull distribution. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
910 |
* \param bound Upper bound on values returned. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
911 |
* \return A floating point random value. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
912 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
913 |
* Note that antithetic values are being generated if |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
914 |
* m_isAntithetic is equal to true. If \f$u\f$ is a uniform variable |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
915 |
* over [0,1] and |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
916 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
917 |
* \f[ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
918 |
* x = scale * {(-\log(u))}^{\frac{1}{shape}} |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
919 |
* \f] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
920 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
921 |
* is a value that would be returned normally, then \f$(1 - u\f$) is |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
922 |
* the distance that \f$u\f$ would be from \f$1\f$. The value |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
923 |
* returned in the antithetic case, \f$x'\f$, is calculated as |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
924 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
925 |
* \f[ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
926 |
* x' = scale * {(-\log(1 - u))}^{\frac{1}{shape}} , |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
927 |
* \f] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
928 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
929 |
* which now involves the log of the distance \f$u\f$ is from 1. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
930 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
931 |
double GetValue (double scale, double shape, double bound); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
932 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
933 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
934 |
* \brief Returns a random unsigned integer from a Weibull distribution with the specified scale, shape, and upper bound. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
935 |
* \param scale Scale parameter for the Weibull distribution. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
936 |
* \param shape Shape parameter for the Weibull distribution. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
937 |
* \param bound Upper bound on values returned. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
938 |
* \return A random unsigned integer value. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
939 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
940 |
* Note that antithetic values are being generated if |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
941 |
* m_isAntithetic is equal to true. If \f$u\f$ is a uniform variable |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
942 |
* over [0,1] and |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
943 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
944 |
* \f[ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
945 |
* x = scale * {(-\log(u))}^{\frac{1}{shape}} |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
946 |
* \f] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
947 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
948 |
* is a value that would be returned normally, then \f$(1 - u\f$) is |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
949 |
* the distance that \f$u\f$ would be from \f$1\f$. The value |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
950 |
* returned in the antithetic case, \f$x'\f$, is calculated as |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
951 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
952 |
* \f[ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
953 |
* x' = scale * {(-\log(1 - u))}^{\frac{1}{shape}} , |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
954 |
* \f] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
955 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
956 |
* which now involves the log of the distance \f$u\f$ is from 1. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
957 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
958 |
uint32_t GetInteger (uint32_t scale, uint32_t shape, uint32_t bound); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
959 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
960 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
961 |
* \brief Returns a random double from a Weibull distribution with the current scale, shape, and upper bound. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
962 |
* \return A floating point random value. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
963 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
964 |
* Note that antithetic values are being generated if |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
965 |
* m_isAntithetic is equal to true. If \f$u\f$ is a uniform variable |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
966 |
* over [0,1] and |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
967 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
968 |
* \f[ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
969 |
* x = scale * {(-\log(u))}^{\frac{1}{shape}} |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
970 |
* \f] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
971 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
972 |
* is a value that would be returned normally, then \f$(1 - u\f$) is |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
973 |
* the distance that \f$u\f$ would be from \f$1\f$. The value |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
974 |
* returned in the antithetic case, \f$x'\f$, is calculated as |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
975 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
976 |
* \f[ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
977 |
* x' = scale * {(-\log(1 - u))}^{\frac{1}{shape}} , |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
978 |
* \f] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
979 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
980 |
* which now involves the log of the distance \f$u\f$ is from 1. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
981 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
982 |
* Note that we have to re-implement this method here because the method is |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
983 |
* overloaded above for the three-argument variant and the c++ name resolution |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
984 |
* rules don't work well with overloads split between parent and child |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
985 |
* classes. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
986 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
987 |
virtual double GetValue (void); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
988 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
989 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
990 |
* \brief Returns a random unsigned integer from a Weibull distribution with the current scale, shape, and upper bound. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
991 |
* \return A random unsigned integer value. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
992 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
993 |
* Note that antithetic values are being generated if |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
994 |
* m_isAntithetic is equal to true. If \f$u\f$ is a uniform variable |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
995 |
* over [0,1] and |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
996 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
997 |
* \f[ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
998 |
* x = scale * {(-\log(u))}^{\frac{1}{shape}} |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
999 |
* \f] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1000 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1001 |
* is a value that would be returned normally, then \f$(1 - u\f$) is |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1002 |
* the distance that \f$u\f$ would be from \f$1\f$. The value |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1003 |
* returned in the antithetic case, \f$x'\f$, is calculated as |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1004 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1005 |
* \f[ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1006 |
* x' = scale * {(-\log(1 - u))}^{\frac{1}{shape}} , |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1007 |
* \f] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1008 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1009 |
* which now involves the log of the distance \f$u\f$ is from 1. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1010 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1011 |
virtual uint32_t GetInteger (void); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1012 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1013 |
private: |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1014 |
/** The scale parameter for the Weibull distribution returned by this RNG stream. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1015 |
double m_scale; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1016 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1017 |
/** The shape parameter for the Weibull distribution returned by this RNG stream. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1018 |
double m_shape; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1019 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1020 |
/** The upper bound on values that can be returned by this RNG stream. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1021 |
double m_bound; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1022 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1023 |
}; // class WeibullRandomVariable |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1024 |
|
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1025 |
|
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1026 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1027 |
* \ingroup randomvariable |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1028 |
* \brief The normal (Gaussian) distribution Random Number Generator |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1029 |
* (RNG) that allows stream numbers to be set deterministically. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1030 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1031 |
* This class supports the creation of objects that return random numbers |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1032 |
* from a fixed normal distribution. It also supports the generation of |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1033 |
* single random numbers from various normal distributions. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1034 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1035 |
* The density probability function is defined over the interval (\f$-\infty\f$,\f$+\infty\f$) |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1036 |
* as: \f$ \frac{1}{\sigma\sqrt{2\pi}} e^{-\frac{(x-\mu)^2}{s\sigma^2}}\f$ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1037 |
* where \f$ mean = \mu \f$ and \f$ variance = \sigma^2 \f$ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1038 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1039 |
* Since normal distributions can theoretically return unbounded |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1040 |
* values, it is sometimes useful to specify a fixed bound. The |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1041 |
* NormalRandomVariable is bounded symmetrically about the mean by |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1042 |
* this bound, i.e. its values are confined to the interval |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1043 |
* [\f$mean-bound\f$,\f$mean+bound\f$]. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1044 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1045 |
* Here is an example of how to use this class: |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1046 |
* \code |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1047 |
* double mean = 5.0; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1048 |
* double variance = 2.0; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1049 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1050 |
* Ptr<NormalRandomVariable> x = CreateObject<NormalRandomVariable> (); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1051 |
* x->SetAttribute ("Mean", DoubleValue (mean)); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1052 |
* x->SetAttribute ("Variance", DoubleValue (variance)); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1053 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1054 |
* // The expected value for the mean of the values returned by a |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1055 |
* // normally distributed random variable is equal to mean. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1056 |
* double value = x->GetValue (); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1057 |
* \endcode |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1058 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1059 |
class NormalRandomVariable : public RandomVariableStream |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1060 |
{ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1061 |
public: |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1062 |
/** Large constant to bound the range. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1063 |
static const double INFINITE_VALUE; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1064 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1065 |
/** |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1066 |
* \brief Register this type. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1067 |
* \return The object TypeId. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1068 |
*/ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1069 |
static TypeId GetTypeId (void); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1070 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1071 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1072 |
* \brief Creates a normal distribution RNG with the default |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1073 |
* values for the mean, variance, and bound. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1074 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1075 |
NormalRandomVariable (); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1076 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1077 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1078 |
* \brief Returns the mean value for the normal distribution returned by this RNG stream. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1079 |
* \return The mean value for the normal distribution returned by this RNG stream. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1080 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1081 |
double GetMean (void) const; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1082 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1083 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1084 |
* \brief Returns the variance value for the normal distribution returned by this RNG stream. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1085 |
* \return The variance value for the normal distribution returned by this RNG stream. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1086 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1087 |
double GetVariance (void) const; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1088 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1089 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1090 |
* \brief Returns the bound on values that can be returned by this RNG stream. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1091 |
* \return The bound on values that can be returned by this RNG stream. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1092 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1093 |
double GetBound (void) const; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1094 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1095 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1096 |
* \brief Returns a random double from a normal distribution with the specified mean, variance, and bound. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1097 |
* \param mean Mean value for the normal distribution. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1098 |
* \param variance Variance value for the normal distribution. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1099 |
* \param bound Bound on values returned. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1100 |
* \return A floating point random value. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1101 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1102 |
* Note that antithetic values are being generated if m_isAntithetic |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1103 |
* is equal to true. If \f$u1\f$ and \f$u2\f$ are uniform variables |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1104 |
* over [0,1], then the values that would be returned normally, \f$x1\f$ and \f$x2\f$, are calculated as follows: |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1105 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1106 |
* \f{eqnarray*}{ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1107 |
* v1 & = & 2 * u1 - 1 \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1108 |
* v2 & = & 2 * u2 - 1 \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1109 |
* w & = & v1 * v1 + v2 * v2 \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1110 |
* y & = & \sqrt{\frac{-2 * \log(w)}{w}} \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1111 |
* x1 & = & mean + v1 * y * \sqrt{variance} \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1112 |
* x2 & = & mean + v2 * y * \sqrt{variance} . |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1113 |
* \f} |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1114 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1115 |
* For the antithetic case, \f$(1 - u1\f$) and \f$(1 - u2\f$) are |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1116 |
* the distances that \f$u1\f$ and \f$u2\f$ would be from \f$1\f$. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1117 |
* The antithetic values returned, \f$x1'\f$ and \f$x2'\f$, are |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1118 |
* calculated as follows: |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1119 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1120 |
* \f{eqnarray*}{ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1121 |
* v1' & = & 2 * (1 - u1) - 1 \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1122 |
* v2' & = & 2 * (1 - u2) - 1 \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1123 |
* w' & = & v1' * v1' + v2' * v2' \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1124 |
* y' & = & \sqrt{\frac{-2 * \log(w')}{w'}} \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1125 |
* x1' & = & mean + v1' * y' * \sqrt{variance} \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1126 |
* x2' & = & mean + v2' * y' * \sqrt{variance} , |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1127 |
* \f} |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1128 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1129 |
* which now involves the distances \f$u1\f$ and \f$u2\f$ are from 1. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1130 |
*/ |
9013
09e1ef298c51
Make bound use a default argument
Tom Henderson <tomh@tomh.org>
parents:
8872
diff
changeset
|
1131 |
double GetValue (double mean, double variance, double bound = NormalRandomVariable::INFINITE_VALUE); |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1132 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1133 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1134 |
* \brief Returns a random unsigned integer from a normal distribution with the specified mean, variance, and bound. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1135 |
* \param mean Mean value for the normal distribution. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1136 |
* \param variance Variance value for the normal distribution. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1137 |
* \param bound Bound on values returned. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1138 |
* \return A random unsigned integer value. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1139 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1140 |
* Note that antithetic values are being generated if m_isAntithetic |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1141 |
* is equal to true. If \f$u1\f$ and \f$u2\f$ are uniform variables |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1142 |
* over [0,1], then the values that would be returned normally, \f$x1\f$ and \f$x2\f$, are calculated as follows: |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1143 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1144 |
* \f{eqnarray*}{ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1145 |
* v1 & = & 2 * u1 - 1 \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1146 |
* v2 & = & 2 * u2 - 1 \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1147 |
* w & = & v1 * v1 + v2 * v2 \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1148 |
* y & = & \sqrt{\frac{-2 * \log(w)}{w}} \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1149 |
* x1 & = & mean + v1 * y * \sqrt{variance} \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1150 |
* x2 & = & mean + v2 * y * \sqrt{variance} . |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1151 |
* \f} |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1152 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1153 |
* For the antithetic case, \f$(1 - u1\f$) and \f$(1 - u2\f$) are |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1154 |
* the distances that \f$u1\f$ and \f$u2\f$ would be from \f$1\f$. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1155 |
* The antithetic values returned, \f$x1'\f$ and \f$x2'\f$, are |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1156 |
* calculated as follows: |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1157 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1158 |
* \f{eqnarray*}{ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1159 |
* v1' & = & 2 * (1 - u1) - 1 \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1160 |
* v2' & = & 2 * (1 - u2) - 1 \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1161 |
* w' & = & v1' * v1' + v2' * v2' \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1162 |
* y' & = & \sqrt{\frac{-2 * \log(w')}{w'}} \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1163 |
* x1' & = & mean + v1' * y' * \sqrt{variance} \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1164 |
* x2' & = & mean + v2' * y' * \sqrt{variance} , |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1165 |
* \f} |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1166 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1167 |
* which now involves the distances \f$u1\f$ and \f$u2\f$ are from 1. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1168 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1169 |
uint32_t GetInteger (uint32_t mean, uint32_t variance, uint32_t bound); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1170 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1171 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1172 |
* \brief Returns a random double from a normal distribution with the current mean, variance, and bound. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1173 |
* \return A floating point random value. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1174 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1175 |
* Note that antithetic values are being generated if m_isAntithetic |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1176 |
* is equal to true. If \f$u1\f$ and \f$u2\f$ are uniform variables |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1177 |
* over [0,1], then the values that would be returned normally, \f$x1\f$ and \f$x2\f$, are calculated as follows: |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1178 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1179 |
* \f{eqnarray*}{ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1180 |
* v1 & = & 2 * u1 - 1 \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1181 |
* v2 & = & 2 * u2 - 1 \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1182 |
* w & = & v1 * v1 + v2 * v2 \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1183 |
* y & = & \sqrt{\frac{-2 * \log(w)}{w}} \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1184 |
* x1 & = & mean + v1 * y * \sqrt{variance} \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1185 |
* x2 & = & mean + v2 * y * \sqrt{variance} . |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1186 |
* \f} |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1187 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1188 |
* For the antithetic case, \f$(1 - u1\f$) and \f$(1 - u2\f$) are |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1189 |
* the distances that \f$u1\f$ and \f$u2\f$ would be from \f$1\f$. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1190 |
* The antithetic values returned, \f$x1'\f$ and \f$x2'\f$, are |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1191 |
* calculated as follows: |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1192 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1193 |
* \f{eqnarray*}{ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1194 |
* v1' & = & 2 * (1 - u1) - 1 \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1195 |
* v2' & = & 2 * (1 - u2) - 1 \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1196 |
* w' & = & v1' * v1' + v2' * v2' \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1197 |
* y' & = & \sqrt{\frac{-2 * \log(w')}{w'}} \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1198 |
* x1' & = & mean + v1' * y' * \sqrt{variance} \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1199 |
* x2' & = & mean + v2' * y' * \sqrt{variance} , |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1200 |
* \f} |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1201 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1202 |
* which now involves the distances \f$u1\f$ and \f$u2\f$ are from 1. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1203 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1204 |
* Note that we have to re-implement this method here because the method is |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1205 |
* overloaded above for the three-argument variant and the c++ name resolution |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1206 |
* rules don't work well with overloads split between parent and child |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1207 |
* classes. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1208 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1209 |
virtual double GetValue (void); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1210 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1211 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1212 |
* \brief Returns a random unsigned integer from a normal distribution with the current mean, variance, and bound. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1213 |
* \return A random unsigned integer value. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1214 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1215 |
* Note that antithetic values are being generated if m_isAntithetic |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1216 |
* is equal to true. If \f$u1\f$ and \f$u2\f$ are uniform variables |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1217 |
* over [0,1], then the values that would be returned normally, \f$x1\f$ and \f$x2\f$, are calculated as follows: |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1218 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1219 |
* \f{eqnarray*}{ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1220 |
* v1 & = & 2 * u1 - 1 \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1221 |
* v2 & = & 2 * u2 - 1 \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1222 |
* w & = & v1 * v1 + v2 * v2 \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1223 |
* y & = & \sqrt{\frac{-2 * \log(w)}{w}} \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1224 |
* x1 & = & mean + v1 * y * \sqrt{variance} \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1225 |
* x2 & = & mean + v2 * y * \sqrt{variance} . |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1226 |
* \f} |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1227 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1228 |
* For the antithetic case, \f$(1 - u1\f$) and \f$(1 - u2\f$) are |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1229 |
* the distances that \f$u1\f$ and \f$u2\f$ would be from \f$1\f$. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1230 |
* The antithetic values returned, \f$x1'\f$ and \f$x2'\f$, are |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1231 |
* calculated as follows: |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1232 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1233 |
* \f{eqnarray*}{ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1234 |
* v1' & = & 2 * (1 - u1) - 1 \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1235 |
* v2' & = & 2 * (1 - u2) - 1 \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1236 |
* w' & = & v1' * v1' + v2' * v2' \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1237 |
* y' & = & \sqrt{\frac{-2 * \log(w')}{w'}} \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1238 |
* x1' & = & mean + v1' * y' * \sqrt{variance} \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1239 |
* x2' & = & mean + v2' * y' * \sqrt{variance} , |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1240 |
* \f} |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1241 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1242 |
* which now involves the distances \f$u1\f$ and \f$u2\f$ are from 1. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1243 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1244 |
virtual uint32_t GetInteger (void); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1245 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1246 |
private: |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1247 |
/** The mean value for the normal distribution returned by this RNG stream. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1248 |
double m_mean; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1249 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1250 |
/** The variance value for the normal distribution returned by this RNG stream. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1251 |
double m_variance; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1252 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1253 |
/** The bound on values that can be returned by this RNG stream. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1254 |
double m_bound; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1255 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1256 |
/** True if the next value is valid. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1257 |
bool m_nextValid; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1258 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1259 |
/** The algorithm produces two values at a time. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1260 |
double m_next; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1261 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1262 |
}; // class NormalRandomVariable |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1263 |
|
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1264 |
|
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1265 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1266 |
* \ingroup randomvariable |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1267 |
* \brief The log-normal distribution Random Number Generator |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1268 |
* (RNG) that allows stream numbers to be set deterministically. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1269 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1270 |
* This class supports the creation of objects that return random numbers |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1271 |
* from a fixed log-normal distribution. It also supports the generation of |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1272 |
* single random numbers from various log-normal distributions. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1273 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1274 |
* LogNormalRandomVariable defines a random variable with a log-normal |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1275 |
* distribution. If one takes the natural logarithm of random |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1276 |
* variable following the log-normal distribution, the obtained values |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1277 |
* follow a normal distribution. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1278 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1279 |
* The probability density function is defined over the interval [0,\f$+\infty\f$) as: |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1280 |
* \f$ \frac{1}{x\sigma\sqrt{2\pi}} e^{-\frac{(ln(x) - \mu)^2}{2\sigma^2}}\f$ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1281 |
* where \f$ mean = e^{\mu+\frac{\sigma^2}{2}} \f$ and |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1282 |
* \f$ variance = (e^{\sigma^2}-1)e^{2\mu+\sigma^2}\f$ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1283 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1284 |
* The \f$ \mu \f$ and \f$ \sigma \f$ parameters can be calculated instead if |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1285 |
* the mean and variance are known with the following equations: |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1286 |
* \f$ \mu = ln(mean) - \frac{1}{2}ln\left(1+\frac{variance}{mean^2}\right)\f$, and, |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1287 |
* \f$ \sigma = \sqrt{ln\left(1+\frac{variance}{mean^2}\right)}\f$ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1288 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1289 |
* Here is an example of how to use this class: |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1290 |
* \code |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1291 |
* double mu = 5.0; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1292 |
* double sigma = 2.0; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1293 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1294 |
* Ptr<LogNormalRandomVariable> x = CreateObject<LogNormalRandomVariable> (); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1295 |
* x->SetAttribute ("Mu", DoubleValue (mu)); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1296 |
* x->SetAttribute ("Sigma", DoubleValue (sigma)); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1297 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1298 |
* // The expected value for the mean of the values returned by a |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1299 |
* // log-normally distributed random variable is equal to |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1300 |
* // |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1301 |
* // 2 |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1302 |
* // mu + sigma / 2 |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1303 |
* // E[value] = e . |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1304 |
* // |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1305 |
* double value = x->GetValue (); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1306 |
* \endcode |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1307 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1308 |
class LogNormalRandomVariable : public RandomVariableStream |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1309 |
{ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1310 |
public: |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1311 |
/** |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1312 |
* \brief Register this type. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1313 |
* \return The object TypeId. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1314 |
*/ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1315 |
static TypeId GetTypeId (void); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1316 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1317 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1318 |
* \brief Creates a log-normal distribution RNG with the default |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1319 |
* values for mu and sigma. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1320 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1321 |
LogNormalRandomVariable (); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1322 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1323 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1324 |
* \brief Returns the mu value for the log-normal distribution returned by this RNG stream. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1325 |
* \return The mu value for the log-normal distribution returned by this RNG stream. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1326 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1327 |
double GetMu (void) const; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1328 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1329 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1330 |
* \brief Returns the sigma value for the log-normal distribution returned by this RNG stream. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1331 |
* \return The sigma value for the log-normal distribution returned by this RNG stream. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1332 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1333 |
double GetSigma (void) const; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1334 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1335 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1336 |
* \brief Returns a random double from a log-normal distribution with the specified mu and sigma. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1337 |
* \param mu Mu value for the log-normal distribution. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1338 |
* \param sigma Sigma value for the log-normal distribution. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1339 |
* \return A floating point random value. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1340 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1341 |
* Note that antithetic values are being generated if m_isAntithetic |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1342 |
* is equal to true. If \f$u1\f$ and \f$u2\f$ are uniform variables |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1343 |
* over [0,1], then the value that would be returned normally, \f$x\f$, is calculated as follows: |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1344 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1345 |
* \f{eqnarray*}{ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1346 |
* v1 & = & -1 + 2 * u1 \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1347 |
* v2 & = & -1 + 2 * u2 \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1348 |
* r2 & = & v1 * v1 + v2 * v2 \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1349 |
* normal & = & v1 * \sqrt{\frac{-2.0 * \log{r2}}{r2}} \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1350 |
* x & = & \exp{sigma * normal + mu} . |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1351 |
* \f} |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1352 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1353 |
* For the antithetic case, \f$(1 - u1\f$) and \f$(1 - u2\f$) are |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1354 |
* the distances that \f$u1\f$ and \f$u2\f$ would be from \f$1\f$. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1355 |
* The antithetic value returned, \f$x'\f$, is calculated as |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1356 |
* follows: |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1357 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1358 |
* \f{eqnarray*}{ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1359 |
* v1' & = & -1 + 2 * (1 - u1) \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1360 |
* v2' & = & -1 + 2 * (1 - u2) \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1361 |
* r2' & = & v1' * v1' + v2' * v2' \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1362 |
* normal' & = & v1' * \sqrt{\frac{-2.0 * \log{r2'}}{r2'}} \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1363 |
* x' & = & \exp{sigma * normal' + mu} . |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1364 |
* \f} |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1365 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1366 |
* which now involves the distances \f$u1\f$ and \f$u2\f$ are from 1. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1367 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1368 |
double GetValue (double mu, double sigma); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1369 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1370 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1371 |
* \brief Returns a random unsigned integer from a log-normal distribution with the specified mu and sigma. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1372 |
* \param mu Mu value for the log-normal distribution. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1373 |
* \param sigma Sigma value for the log-normal distribution. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1374 |
* \return A random unsigned integer value. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1375 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1376 |
* Note that antithetic values are being generated if m_isAntithetic |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1377 |
* is equal to true. If \f$u1\f$ and \f$u2\f$ are uniform variables |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1378 |
* over [0,1], then the value that would be returned normally, \f$x\f$, is calculated as follows: |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1379 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1380 |
* \f{eqnarray*}{ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1381 |
* v1 & = & -1 + 2 * u1 \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1382 |
* v2 & = & -1 + 2 * u2 \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1383 |
* r2 & = & v1 * v1 + v2 * v2 \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1384 |
* normal & = & v1 * \sqrt{\frac{-2.0 * \log{r2}}{r2}} \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1385 |
* x & = & \exp{sigma * normal + mu} . |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1386 |
* \f} |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1387 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1388 |
* For the antithetic case, \f$(1 - u1\f$) and \f$(1 - u2\f$) are |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1389 |
* the distances that \f$u1\f$ and \f$u2\f$ would be from \f$1\f$. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1390 |
* The antithetic value returned, \f$x'\f$, is calculated as |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1391 |
* follows: |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1392 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1393 |
* \f{eqnarray*}{ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1394 |
* v1' & = & -1 + 2 * (1 - u1) \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1395 |
* v2' & = & -1 + 2 * (1 - u2) \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1396 |
* r2' & = & v1' * v1' + v2' * v2' \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1397 |
* normal' & = & v1' * \sqrt{\frac{-2.0 * \log{r2'}}{r2'}} \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1398 |
* x' & = & \exp{sigma * normal' + mu} . |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1399 |
* \f} |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1400 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1401 |
* which now involves the distances \f$u1\f$ and \f$u2\f$ are from 1. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1402 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1403 |
uint32_t GetInteger (uint32_t mu, uint32_t sigma); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1404 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1405 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1406 |
* \brief Returns a random double from a log-normal distribution with the current mu and sigma. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1407 |
* \return A floating point random value. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1408 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1409 |
* Note that antithetic values are being generated if m_isAntithetic |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1410 |
* is equal to true. If \f$u1\f$ and \f$u2\f$ are uniform variables |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1411 |
* over [0,1], then the value that would be returned normally, \f$x\f$, is calculated as follows: |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1412 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1413 |
* \f{eqnarray*}{ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1414 |
* v1 & = & -1 + 2 * u1 \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1415 |
* v2 & = & -1 + 2 * u2 \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1416 |
* r2 & = & v1 * v1 + v2 * v2 \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1417 |
* normal & = & v1 * \sqrt{\frac{-2.0 * \log{r2}}{r2}} \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1418 |
* x & = & \exp{sigma * normal + mu} . |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1419 |
* \f} |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1420 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1421 |
* For the antithetic case, \f$(1 - u1\f$) and \f$(1 - u2\f$) are |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1422 |
* the distances that \f$u1\f$ and \f$u2\f$ would be from \f$1\f$. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1423 |
* The antithetic value returned, \f$x'\f$, is calculated as |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1424 |
* follows: |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1425 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1426 |
* \f{eqnarray*}{ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1427 |
* v1' & = & -1 + 2 * (1 - u1) \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1428 |
* v2' & = & -1 + 2 * (1 - u2) \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1429 |
* r2' & = & v1' * v1' + v2' * v2' \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1430 |
* normal' & = & v1' * \sqrt{\frac{-2.0 * \log{r2'}}{r2'}} \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1431 |
* x' & = & \exp{sigma * normal' + mu} . |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1432 |
* \f} |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1433 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1434 |
* which now involves the distances \f$u1\f$ and \f$u2\f$ are from 1. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1435 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1436 |
* Note that we have to re-implement this method here because the method is |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1437 |
* overloaded above for the two-argument variant and the c++ name resolution |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1438 |
* rules don't work well with overloads split between parent and child |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1439 |
* classes. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1440 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1441 |
virtual double GetValue (void); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1442 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1443 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1444 |
* \brief Returns a random unsigned integer from a log-normal distribution with the current mu and sigma. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1445 |
* \return A random unsigned integer value. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1446 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1447 |
* Note that antithetic values are being generated if m_isAntithetic |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1448 |
* is equal to true. If \f$u1\f$ and \f$u2\f$ are uniform variables |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1449 |
* over [0,1], then the value that would be returned normally, \f$x\f$, is calculated as follows: |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1450 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1451 |
* \f{eqnarray*}{ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1452 |
* v1 & = & -1 + 2 * u1 \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1453 |
* v2 & = & -1 + 2 * u2 \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1454 |
* r2 & = & v1 * v1 + v2 * v2 \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1455 |
* normal & = & v1 * \sqrt{\frac{-2.0 * \log{r2}}{r2}} \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1456 |
* x & = & \exp{sigma * normal + mu} . |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1457 |
* \f} |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1458 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1459 |
* For the antithetic case, \f$(1 - u1\f$) and \f$(1 - u2\f$) are |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1460 |
* the distances that \f$u1\f$ and \f$u2\f$ would be from \f$1\f$. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1461 |
* The antithetic value returned, \f$x'\f$, is calculated as |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1462 |
* follows: |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1463 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1464 |
* \f{eqnarray*}{ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1465 |
* v1' & = & -1 + 2 * (1 - u1) \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1466 |
* v2' & = & -1 + 2 * (1 - u2) \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1467 |
* r2' & = & v1' * v1' + v2' * v2' \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1468 |
* normal' & = & v1' * \sqrt{\frac{-2.0 * \log{r2'}}{r2'}} \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1469 |
* x' & = & \exp{sigma * normal' + mu} . |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1470 |
* \f} |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1471 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1472 |
* which now involves the distances \f$u1\f$ and \f$u2\f$ are from 1. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1473 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1474 |
virtual uint32_t GetInteger (void); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1475 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1476 |
private: |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1477 |
/** The mu value for the log-normal distribution returned by this RNG stream. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1478 |
double m_mu; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1479 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1480 |
/** The sigma value for the log-normal distribution returned by this RNG stream. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1481 |
double m_sigma; |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1482 |
|
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1483 |
}; // class LogNormalRandomVariable |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1484 |
|
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1485 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1486 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1487 |
* \ingroup randomvariable |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1488 |
* \brief The gamma distribution Random Number Generator (RNG) that |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1489 |
* allows stream numbers to be set deterministically. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1490 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1491 |
* This class supports the creation of objects that return random numbers |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1492 |
* from a fixed gamma distribution. It also supports the generation of |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1493 |
* single random numbers from various gamma distributions. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1494 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1495 |
* The probability density function is defined over the interval [0,\f$+\infty\f$) as: |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1496 |
* \f$ x^{\alpha-1} \frac{e^{-\frac{x}{\beta}}}{\beta^\alpha \Gamma(\alpha)}\f$ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1497 |
* where \f$ mean = \alpha\beta \f$ and |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1498 |
* \f$ variance = \alpha \beta^2\f$ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1499 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1500 |
* Here is an example of how to use this class: |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1501 |
* \code |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1502 |
* double alpha = 5.0; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1503 |
* double beta = 2.0; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1504 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1505 |
* Ptr<GammaRandomVariable> x = CreateObject<GammaRandomVariable> (); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1506 |
* x->SetAttribute ("Alpha", DoubleValue (alpha)); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1507 |
* x->SetAttribute ("Beta", DoubleValue (beta)); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1508 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1509 |
* // The expected value for the mean of the values returned by a |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1510 |
* // gammaly distributed random variable is equal to |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1511 |
* // |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1512 |
* // E[value] = alpha * beta . |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1513 |
* // |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1514 |
* double value = x->GetValue (); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1515 |
* \endcode |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1516 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1517 |
class GammaRandomVariable : public RandomVariableStream |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1518 |
{ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1519 |
public: |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1520 |
/** |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1521 |
* \brief Register this type. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1522 |
* \return The object TypeId. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1523 |
*/ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1524 |
static TypeId GetTypeId (void); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1525 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1526 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1527 |
* \brief Creates a gamma distribution RNG with the default values |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1528 |
* for alpha and beta. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1529 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1530 |
GammaRandomVariable (); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1531 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1532 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1533 |
* \brief Returns the alpha value for the gamma distribution returned by this RNG stream. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1534 |
* \return The alpha value for the gamma distribution returned by this RNG stream. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1535 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1536 |
double GetAlpha (void) const; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1537 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1538 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1539 |
* \brief Returns the beta value for the gamma distribution returned by this RNG stream. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1540 |
* \return The beta value for the gamma distribution returned by this RNG stream. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1541 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1542 |
double GetBeta (void) const; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1543 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1544 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1545 |
* \brief Returns a random double from a gamma distribution with the specified alpha and beta. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1546 |
* \param alpha Alpha value for the gamma distribution. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1547 |
* \param beta Beta value for the gamma distribution. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1548 |
* \return A floating point random value. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1549 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1550 |
* Note that antithetic values are being generated if m_isAntithetic |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1551 |
* is equal to true. If \f$u\f$ is a uniform variable over [0,1] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1552 |
* and \f$x\f$ is a value that would be returned normally, then |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1553 |
* \f$(1 - u\f$) is the distance that \f$u\f$ would be from \f$1\f$. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1554 |
* The value returned in the antithetic case, \f$x'\f$, uses (1-u), |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1555 |
* which is the distance \f$u\f$ is from the 1. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1556 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1557 |
double GetValue (double alpha, double beta); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1558 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1559 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1560 |
* \brief Returns a random unsigned integer from a gamma distribution with the specified alpha and beta. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1561 |
* \param alpha Alpha value for the gamma distribution. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1562 |
* \param beta Beta value for the gamma distribution. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1563 |
* \return A random unsigned integer value. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1564 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1565 |
* Note that antithetic values are being generated if m_isAntithetic |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1566 |
* is equal to true. If \f$u\f$ is a uniform variable over [0,1] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1567 |
* and \f$x\f$ is a value that would be returned normally, then |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1568 |
* \f$(1 - u\f$) is the distance that \f$u\f$ would be from \f$1\f$. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1569 |
* The value returned in the antithetic case, \f$x'\f$, uses (1-u), |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1570 |
* which is the distance \f$u\f$ is from the 1. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1571 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1572 |
uint32_t GetInteger (uint32_t alpha, uint32_t beta); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1573 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1574 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1575 |
* \brief Returns a random double from a gamma distribution with the current alpha and beta. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1576 |
* \return A floating point random value. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1577 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1578 |
* Note that antithetic values are being generated if m_isAntithetic |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1579 |
* is equal to true. If \f$u\f$ is a uniform variable over [0,1] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1580 |
* and \f$x\f$ is a value that would be returned normally, then |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1581 |
* \f$(1 - u\f$) is the distance that \f$u\f$ would be from \f$1\f$. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1582 |
* The value returned in the antithetic case, \f$x'\f$, uses (1-u), |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1583 |
* which is the distance \f$u\f$ is from the 1. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1584 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1585 |
* Note that we have to re-implement this method here because the method is |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1586 |
* overloaded above for the two-argument variant and the c++ name resolution |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1587 |
* rules don't work well with overloads split between parent and child |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1588 |
* classes. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1589 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1590 |
virtual double GetValue (void); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1591 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1592 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1593 |
* \brief Returns a random unsigned integer from a gamma distribution with the current alpha and beta. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1594 |
* \return A random unsigned integer value. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1595 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1596 |
* Note that antithetic values are being generated if m_isAntithetic |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1597 |
* is equal to true. If \f$u\f$ is a uniform variable over [0,1] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1598 |
* and \f$x\f$ is a value that would be returned normally, then |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1599 |
* \f$(1 - u\f$) is the distance that \f$u\f$ would be from \f$1\f$. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1600 |
* The value returned in the antithetic case, \f$x'\f$, uses (1-u), |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1601 |
* which is the distance \f$u\f$ is from the 1. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1602 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1603 |
virtual uint32_t GetInteger (void); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1604 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1605 |
private: |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1606 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1607 |
* \brief Returns a random double from a normal distribution with the specified mean, variance, and bound. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1608 |
* \param mean Mean value for the normal distribution. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1609 |
* \param variance Variance value for the normal distribution. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1610 |
* \param bound Bound on values returned. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1611 |
* \return A floating point random value. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1612 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1613 |
* Note that antithetic values are being generated if m_isAntithetic |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1614 |
* is equal to true. If \f$u1\f$ and \f$u2\f$ are uniform variables |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1615 |
* over [0,1], then the values that would be returned normally, \f$x1\f$ and \f$x2\f$, are calculated as follows: |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1616 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1617 |
* \f{eqnarray*}{ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1618 |
* v1 & = & 2 * u1 - 1 \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1619 |
* v2 & = & 2 * u2 - 1 \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1620 |
* w & = & v1 * v1 + v2 * v2 \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1621 |
* y & = & \sqrt{\frac{-2 * \log(w)}{w}} \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1622 |
* x1 & = & mean + v1 * y * \sqrt{variance} \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1623 |
* x2 & = & mean + v2 * y * \sqrt{variance} . |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1624 |
* \f} |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1625 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1626 |
* For the antithetic case, \f$(1 - u1\f$) and \f$(1 - u2\f$) are |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1627 |
* the distances that \f$u1\f$ and \f$u2\f$ would be from \f$1\f$. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1628 |
* The antithetic values returned, \f$x1'\f$ and \f$x2'\f$, are |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1629 |
* calculated as follows: |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1630 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1631 |
* \f{eqnarray*}{ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1632 |
* v1' & = & 2 * (1 - u1) - 1 \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1633 |
* v2' & = & 2 * (1 - u2) - 1 \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1634 |
* w' & = & v1' * v1' + v2' * v2' \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1635 |
* y' & = & \sqrt{\frac{-2 * \log(w')}{w'}} \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1636 |
* x1' & = & mean + v1' * y' * \sqrt{variance} \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1637 |
* x2' & = & mean + v2' * y' * \sqrt{variance} , |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1638 |
* \f} |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1639 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1640 |
* which now involves the distances \f$u1\f$ and \f$u2\f$ are from 1. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1641 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1642 |
double GetNormalValue (double mean, double variance, double bound); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1643 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1644 |
/** The alpha value for the gamma distribution returned by this RNG stream. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1645 |
double m_alpha; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1646 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1647 |
/** The beta value for the gamma distribution returned by this RNG stream. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1648 |
double m_beta; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1649 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1650 |
/** True if the next normal value is valid. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1651 |
bool m_nextValid; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1652 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1653 |
/** The algorithm produces two normal values at a time. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1654 |
double m_next; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1655 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1656 |
}; // class GammaRandomVariable |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1657 |
|
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1658 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1659 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1660 |
* \ingroup randomvariable |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1661 |
* \brief The Erlang distribution Random Number Generator (RNG) that |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1662 |
* allows stream numbers to be set deterministically. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1663 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1664 |
* This class supports the creation of objects that return random numbers |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1665 |
* from a fixed Erlang distribution. It also supports the generation of |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1666 |
* single random numbers from various Erlang distributions. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1667 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1668 |
* The Erlang distribution is a special case of the Gamma distribution where k |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1669 |
* (= alpha) is a non-negative integer. Erlang distributed variables can be |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1670 |
* generated using a much faster algorithm than gamma variables. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1671 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1672 |
* The probability density function is defined over the interval [0,\f$+\infty\f$) as: |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1673 |
* \f$ \frac{x^{k-1} e^{-\frac{x}{\lambda}}}{\lambda^k (k-1)!}\f$ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1674 |
* where \f$ mean = k \lambda \f$ and |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1675 |
* \f$ variance = k \lambda^2\f$ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1676 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1677 |
* Here is an example of how to use this class: |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1678 |
* \code |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1679 |
* uint32_t k = 5; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1680 |
* double lambda = 2.0; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1681 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1682 |
* Ptr<ErlangRandomVariable> x = CreateObject<ErlangRandomVariable> (); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1683 |
* x->SetAttribute ("K", IntegerValue (k)); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1684 |
* x->SetAttribute ("Lambda", DoubleValue (lambda)); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1685 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1686 |
* // The expected value for the mean of the values returned by a |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1687 |
* // Erlangly distributed random variable is equal to |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1688 |
* // |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1689 |
* // E[value] = k * lambda . |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1690 |
* // |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1691 |
* double value = x->GetValue (); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1692 |
* \endcode |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1693 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1694 |
class ErlangRandomVariable : public RandomVariableStream |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1695 |
{ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1696 |
public: |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1697 |
/** |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1698 |
* \brief Register this type. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1699 |
* \return The object TypeId. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1700 |
*/ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1701 |
static TypeId GetTypeId (void); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1702 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1703 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1704 |
* \brief Creates an Erlang distribution RNG with the default values |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1705 |
* for k and lambda. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1706 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1707 |
ErlangRandomVariable (); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1708 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1709 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1710 |
* \brief Returns the k value for the Erlang distribution returned by this RNG stream. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1711 |
* \return The k value for the Erlang distribution returned by this RNG stream. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1712 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1713 |
uint32_t GetK (void) const; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1714 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1715 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1716 |
* \brief Returns the lambda value for the Erlang distribution returned by this RNG stream. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1717 |
* \return The lambda value for the Erlang distribution returned by this RNG stream. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1718 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1719 |
double GetLambda (void) const; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1720 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1721 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1722 |
* \brief Returns a random double from an Erlang distribution with the specified k and lambda. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1723 |
* \param k K value for the Erlang distribution. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1724 |
* \param lambda Lambda value for the Erlang distribution. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1725 |
* \return A floating point random value. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1726 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1727 |
* Note that antithetic values are being generated if m_isAntithetic |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1728 |
* is equal to true. If \f$u\f$ is a uniform variable over [0,1] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1729 |
* and \f$x\f$ is a value that would be returned normally, then |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1730 |
* \f$(1 - u\f$) is the distance that \f$u\f$ would be from \f$1\f$. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1731 |
* The value returned in the antithetic case, \f$x'\f$, uses (1-u), |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1732 |
* which is the distance \f$u\f$ is from the 1. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1733 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1734 |
double GetValue (uint32_t k, double lambda); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1735 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1736 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1737 |
* \brief Returns a random unsigned integer from an Erlang distribution with the specified k and lambda. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1738 |
* \param k K value for the Erlang distribution. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1739 |
* \param lambda Lambda value for the Erlang distribution. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1740 |
* \return A random unsigned integer value. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1741 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1742 |
* Note that antithetic values are being generated if m_isAntithetic |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1743 |
* is equal to true. If \f$u\f$ is a uniform variable over [0,1] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1744 |
* and \f$x\f$ is a value that would be returned normally, then |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1745 |
* \f$(1 - u\f$) is the distance that \f$u\f$ would be from \f$1\f$. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1746 |
* The value returned in the antithetic case, \f$x'\f$, uses (1-u), |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1747 |
* which is the distance \f$u\f$ is from the 1. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1748 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1749 |
uint32_t GetInteger (uint32_t k, uint32_t lambda); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1750 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1751 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1752 |
* \brief Returns a random double from an Erlang distribution with the current k and lambda. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1753 |
* \return A floating point random value. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1754 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1755 |
* Note that antithetic values are being generated if m_isAntithetic |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1756 |
* is equal to true. If \f$u\f$ is a uniform variable over [0,1] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1757 |
* and \f$x\f$ is a value that would be returned normally, then |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1758 |
* \f$(1 - u\f$) is the distance that \f$u\f$ would be from \f$1\f$. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1759 |
* The value returned in the antithetic case, \f$x'\f$, uses (1-u), |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1760 |
* which is the distance \f$u\f$ is from the 1. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1761 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1762 |
* Note that we have to re-implement this method here because the method is |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1763 |
* overloaded above for the two-argument variant and the c++ name resolution |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1764 |
* rules don't work well with overloads split between parent and child |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1765 |
* classes. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1766 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1767 |
virtual double GetValue (void); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1768 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1769 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1770 |
* \brief Returns a random unsigned integer from an Erlang distribution with the current k and lambda. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1771 |
* \return A random unsigned integer value. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1772 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1773 |
* Note that antithetic values are being generated if m_isAntithetic |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1774 |
* is equal to true. If \f$u\f$ is a uniform variable over [0,1] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1775 |
* and \f$x\f$ is a value that would be returned normally, then |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1776 |
* \f$(1 - u\f$) is the distance that \f$u\f$ would be from \f$1\f$. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1777 |
* The value returned in the antithetic case, \f$x'\f$, uses (1-u), |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1778 |
* which is the distance \f$u\f$ is from the 1. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1779 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1780 |
virtual uint32_t GetInteger (void); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1781 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1782 |
private: |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1783 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1784 |
* \brief Returns a random double from an exponential distribution with the specified mean and upper bound. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1785 |
* \param mean Mean value of the random variables. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1786 |
* \param bound Upper bound on values returned. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1787 |
* \return A floating point random value. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1788 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1789 |
* Note that antithetic values are being generated if |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1790 |
* m_isAntithetic is equal to true. If \f$u\f$ is a uniform variable |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1791 |
* over [0,1] and |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1792 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1793 |
* \f[ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1794 |
* x = - mean * \log(u) |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1795 |
* \f] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1796 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1797 |
* is a value that would be returned normally, then \f$(1 - u\f$) is |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1798 |
* the distance that \f$u\f$ would be from \f$1\f$. The value |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1799 |
* returned in the antithetic case, \f$x'\f$, is calculated as |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1800 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1801 |
* \f[ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1802 |
* x' = - mean * \log(1 - u), |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1803 |
* \f] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1804 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1805 |
* which now involves the log of the distance \f$u\f$ is from the 1. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1806 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1807 |
double GetExponentialValue (double mean, double bound); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1808 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1809 |
/** The k value for the Erlang distribution returned by this RNG stream. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1810 |
uint32_t m_k; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1811 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1812 |
/** The lambda value for the Erlang distribution returned by this RNG stream. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1813 |
double m_lambda; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1814 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1815 |
}; // class ErlangRandomVariable |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1816 |
|
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1817 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1818 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1819 |
* \ingroup randomvariable |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1820 |
* \brief The triangular distribution Random Number Generator (RNG) that |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1821 |
* allows stream numbers to be set deterministically. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1822 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1823 |
* This class supports the creation of objects that return random numbers |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1824 |
* from a fixed triangular distribution. It also supports the generation of |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1825 |
* single random numbers from various triangular distributions. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1826 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1827 |
* This distribution is a triangular distribution. The probability density |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1828 |
* is in the shape of a triangle. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1829 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1830 |
* Here is an example of how to use this class: |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1831 |
* \code |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1832 |
* double mean = 5.0; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1833 |
* double min = 2.0; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1834 |
* double max = 10.0; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1835 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1836 |
* Ptr<TriangularRandomVariable> x = CreateObject<TriangularRandomVariable> (); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1837 |
* x->SetAttribute ("Mean", DoubleValue (mean)); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1838 |
* x->SetAttribute ("Min", DoubleValue (min)); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1839 |
* x->SetAttribute ("Max", DoubleValue (max)); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1840 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1841 |
* // The expected value for the mean of the values returned by a |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1842 |
* // triangularly distributed random variable is equal to mean. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1843 |
* double value = x->GetValue (); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1844 |
* \endcode |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1845 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1846 |
class TriangularRandomVariable : public RandomVariableStream |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1847 |
{ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1848 |
public: |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1849 |
/** |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1850 |
* \brief Register this type. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1851 |
* \return The object TypeId. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
1852 |
*/ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1853 |
static TypeId GetTypeId (void); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1854 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1855 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1856 |
* \brief Creates a triangular distribution RNG with the default |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1857 |
* values for the mean, lower bound, and upper bound. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1858 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1859 |
TriangularRandomVariable (); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1860 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1861 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1862 |
* \brief Returns the mean value for the triangular distribution returned by this RNG stream. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1863 |
* \return The mean value for the triangular distribution returned by this RNG stream. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1864 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1865 |
double GetMean (void) const; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1866 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1867 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1868 |
* \brief Returns the lower bound for the triangular distribution returned by this RNG stream. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1869 |
* \return The lower bound for the triangular distribution returned by this RNG stream. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1870 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1871 |
double GetMin (void) const; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1872 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1873 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1874 |
* \brief Returns the upper bound on values that can be returned by this RNG stream. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1875 |
* \return The upper bound on values that can be returned by this RNG stream. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1876 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1877 |
double GetMax (void) const; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1878 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1879 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1880 |
* \brief Returns a random double from a triangular distribution with the specified mean, min, and max. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1881 |
* \param mean Mean value for the triangular distribution. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1882 |
* \param min Low end of the range. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1883 |
* \param max High end of the range. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1884 |
* \return A floating point random value. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1885 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1886 |
* Note that antithetic values are being generated if |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1887 |
* m_isAntithetic is equal to true. If \f$u\f$ is a uniform variable |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1888 |
* over [0,1] and |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1889 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1890 |
* \f[ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1891 |
* x = \left\{ \begin{array}{rl} |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1892 |
* min + \sqrt{u * (max - min) * (mode - min)} &\mbox{ if $u <= (mode - min)/(max - min)$} \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1893 |
* max - \sqrt{ (1 - u) * (max - min) * (max - mode) } &\mbox{ otherwise} |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1894 |
* \end{array} \right. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1895 |
* \f] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1896 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1897 |
* is a value that would be returned normally, where the mode or |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1898 |
* peak of the triangle is calculated as |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1899 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1900 |
* \f[ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1901 |
* mode = 3.0 * mean - min - max . |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1902 |
* \f] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1903 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1904 |
* Then, \f$(1 - u\f$) is the distance that \f$u\f$ would be from |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1905 |
* \f$1\f$. The value returned in the antithetic case, \f$x'\f$, is |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1906 |
* calculated as |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1907 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1908 |
* \f[ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1909 |
* x' = \left\{ \begin{array}{rl} |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1910 |
* min + \sqrt{(1 - u) * (max - min) * (mode - min)} &\mbox{ if $(1 - u) <= (mode - min)/(max - min)$} \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1911 |
* max - \sqrt{ u * (max - min) * (max - mode) } &\mbox{ otherwise} |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1912 |
* \end{array} \right. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1913 |
* \f] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1914 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1915 |
* which now involves the distance \f$u\f$ is from the 1. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1916 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1917 |
double GetValue (double mean, double min, double max); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1918 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1919 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1920 |
* \brief Returns a random unsigned integer from a triangular distribution with the specified mean, min, and max. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1921 |
* \param mean Mean value for the triangular distribution. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1922 |
* \param min Low end of the range. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1923 |
* \param max High end of the range. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1924 |
* \return A random unsigned integer value. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1925 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1926 |
* Note that antithetic values are being generated if |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1927 |
* m_isAntithetic is equal to true. If \f$u\f$ is a uniform variable |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1928 |
* over [0,1] and |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1929 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1930 |
* \f[ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1931 |
* x = \left\{ \begin{array}{rl} |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1932 |
* min + \sqrt{u * (max - min) * (mode - min)} &\mbox{ if $u <= (mode - min)/(max - min)$} \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1933 |
* max - \sqrt{ (1 - u) * (max - min) * (max - mode) } &\mbox{ otherwise} |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1934 |
* \end{array} \right. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1935 |
* \f] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1936 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1937 |
* is a value that would be returned normally, where the mode or |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1938 |
* peak of the triangle is calculated as |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1939 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1940 |
* \f[ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1941 |
* mode = 3.0 * mean - min - max . |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1942 |
* \f] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1943 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1944 |
* Then, \f$(1 - u\f$) is the distance that \f$u\f$ would be from |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1945 |
* \f$1\f$. The value returned in the antithetic case, \f$x'\f$, is |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1946 |
* calculated as |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1947 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1948 |
* \f[ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1949 |
* x' = \left\{ \begin{array}{rl} |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1950 |
* min + \sqrt{(1 - u) * (max - min) * (mode - min)} &\mbox{ if $(1 - u) <= (mode - min)/(max - min)$} \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1951 |
* max - \sqrt{ u * (max - min) * (max - mode) } &\mbox{ otherwise} |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1952 |
* \end{array} \right. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1953 |
* \f] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1954 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1955 |
* which now involves the distance \f$u\f$ is from the 1. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1956 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1957 |
uint32_t GetInteger (uint32_t mean, uint32_t min, uint32_t max); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1958 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1959 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1960 |
* \brief Returns a random double from a triangular distribution with the current mean, min, and max. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1961 |
* \return A floating point random value. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1962 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1963 |
* Note that antithetic values are being generated if |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1964 |
* m_isAntithetic is equal to true. If \f$u\f$ is a uniform variable |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1965 |
* over [0,1] and |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1966 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1967 |
* \f[ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1968 |
* x = \left\{ \begin{array}{rl} |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1969 |
* min + \sqrt{u * (max - min) * (mode - min)} &\mbox{ if $u <= (mode - min)/(max - min)$} \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1970 |
* max - \sqrt{ (1 - u) * (max - min) * (max - mode) } &\mbox{ otherwise} |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1971 |
* \end{array} \right. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1972 |
* \f] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1973 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1974 |
* is a value that would be returned normally, where the mode or |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1975 |
* peak of the triangle is calculated as |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1976 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1977 |
* \f[ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1978 |
* mode = 3.0 * mean - min - max . |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1979 |
* \f] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1980 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1981 |
* Then, \f$(1 - u\f$) is the distance that \f$u\f$ would be from |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1982 |
* \f$1\f$. The value returned in the antithetic case, \f$x'\f$, is |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1983 |
* calculated as |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1984 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1985 |
* \f[ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1986 |
* x' = \left\{ \begin{array}{rl} |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1987 |
* min + \sqrt{(1 - u) * (max - min) * (mode - min)} &\mbox{ if $(1 - u) <= (mode - min)/(max - min)$} \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1988 |
* max - \sqrt{ u * (max - min) * (max - mode) } &\mbox{ otherwise} |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1989 |
* \end{array} \right. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1990 |
* \f] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1991 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1992 |
* which now involves the distance \f$u\f$ is from the 1. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1993 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1994 |
* Note that we have to re-implement this method here because the method is |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1995 |
* overloaded above for the three-argument variant and the c++ name resolution |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1996 |
* rules don't work well with overloads split between parent and child |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1997 |
* classes. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1998 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
1999 |
virtual double GetValue (void); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2000 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2001 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2002 |
* \brief Returns a random unsigned integer from a triangular distribution with the current mean, min, and max. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2003 |
* \return A random unsigned integer value. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2004 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2005 |
* Note that antithetic values are being generated if |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2006 |
* m_isAntithetic is equal to true. If \f$u\f$ is a uniform variable |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2007 |
* over [0,1] and |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2008 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2009 |
* \f[ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2010 |
* x = \left\{ \begin{array}{rl} |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2011 |
* min + \sqrt{u * (max - min) * (mode - min)} &\mbox{ if $u <= (mode - min)/(max - min)$} \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2012 |
* max - \sqrt{ (1 - u) * (max - min) * (max - mode) } &\mbox{ otherwise} |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2013 |
* \end{array} \right. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2014 |
* \f] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2015 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2016 |
* is a value that would be returned normally, where the mode or |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2017 |
* peak of the triangle is calculated as |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2018 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2019 |
* \f[ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2020 |
* mode = 3.0 * mean - min - max . |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2021 |
* \f] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2022 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2023 |
* Then, \f$(1 - u\f$) is the distance that \f$u\f$ would be from |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2024 |
* \f$1\f$. The value returned in the antithetic case, \f$x'\f$, is |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2025 |
* calculated as |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2026 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2027 |
* \f[ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2028 |
* x' = \left\{ \begin{array}{rl} |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2029 |
* min + \sqrt{(1 - u) * (max - min) * (mode - min)} &\mbox{ if $(1 - u) <= (mode - min)/(max - min)$} \\ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2030 |
* max - \sqrt{ u * (max - min) * (max - mode) } &\mbox{ otherwise} |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2031 |
* \end{array} \right. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2032 |
* \f] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2033 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2034 |
* which now involves the distance \f$u\f$ is from the 1. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2035 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2036 |
virtual uint32_t GetInteger (void); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2037 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2038 |
private: |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2039 |
/** The mean value for the triangular distribution returned by this RNG stream. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2040 |
double m_mean; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2041 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2042 |
/** The lower bound on values that can be returned by this RNG stream. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2043 |
double m_min; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2044 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2045 |
/** The upper bound on values that can be returned by this RNG stream. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2046 |
double m_max; |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2047 |
|
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2048 |
}; // class TriangularRandomVariable |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2049 |
|
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2050 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2051 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2052 |
* \ingroup randomvariable |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2053 |
* \brief The Zipf distribution Random Number Generator (RNG) that |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2054 |
* allows stream numbers to be set deterministically. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2055 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2056 |
* This class supports the creation of objects that return random numbers |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2057 |
* from a fixed Zipf distribution. It also supports the generation of |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2058 |
* single random numbers from various Zipf distributions. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2059 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2060 |
* The Zipf's law states that given some corpus of natural language |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2061 |
* utterances, the frequency of any word is inversely proportional |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2062 |
* to its rank in the frequency table. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2063 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2064 |
* Zipf's distribution has two parameters, alpha and N, where: |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2065 |
* \f$ \alpha > 0 \f$ (real) and \f$ N \in \{1,2,3 \dots\}\f$ (integer). |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2066 |
* Probability Mass Function is \f$ f(k; \alpha, N) = k^{-\alpha}/ H_{N,\alpha} \f$ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2067 |
* where \f$ H_{N,\alpha} = \sum_{m=1}^N m^{-\alpha} \f$ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2068 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2069 |
* Here is an example of how to use this class: |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2070 |
* \code |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2071 |
* uint32_t n = 1; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2072 |
* double alpha = 2.0; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2073 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2074 |
* Ptr<ZipfRandomVariable> x = CreateObject<ZipfRandomVariable> (); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2075 |
* x->SetAttribute ("N", IntegerValue (n)); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2076 |
* x->SetAttribute ("Alpha", DoubleValue (alpha)); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2077 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2078 |
* // The expected value for the mean of the values returned by a |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2079 |
* // Zipfly distributed random variable is equal to |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2080 |
* // |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2081 |
* // H |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2082 |
* // N, alpha - 1 |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2083 |
* // E[value] = --------------- |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2084 |
* // H |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2085 |
* // N, alpha |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2086 |
* // |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2087 |
* // where |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2088 |
* // |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2089 |
* // N |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2090 |
* // --- |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2091 |
* // \ -alpha |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2092 |
* // H = / m . |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2093 |
* // N, alpha --- |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2094 |
* // m=1 |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2095 |
* // |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2096 |
* // For this test, |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2097 |
* // |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2098 |
* // -(alpha - 1) |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2099 |
* // 1 |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2100 |
* // E[value] = --------------- |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2101 |
* // -alpha |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2102 |
* // 1 |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2103 |
* // |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2104 |
* // = 1 . |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2105 |
* // |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2106 |
* double value = x->GetValue (); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2107 |
* \endcode |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2108 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2109 |
class ZipfRandomVariable : public RandomVariableStream |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2110 |
{ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2111 |
public: |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2112 |
/** |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2113 |
* \brief Register this type. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2114 |
* \return The object TypeId. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2115 |
*/ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2116 |
static TypeId GetTypeId (void); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2117 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2118 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2119 |
* \brief Creates a Zipf distribution RNG with the default values |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2120 |
* for n and alpha. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2121 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2122 |
ZipfRandomVariable (); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2123 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2124 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2125 |
* \brief Returns the n value for the Zipf distribution returned by this RNG stream. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2126 |
* \return The n value for the Zipf distribution returned by this RNG stream. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2127 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2128 |
uint32_t GetN (void) const; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2129 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2130 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2131 |
* \brief Returns the alpha value for the Zipf distribution returned by this RNG stream. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2132 |
* \return The alpha value for the Zipf distribution returned by this RNG stream. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2133 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2134 |
double GetAlpha (void) const; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2135 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2136 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2137 |
* \brief Returns a random double from a Zipf distribution with the specified n and alpha. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2138 |
* \param n N value for the Zipf distribution. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2139 |
* \param alpha Alpha value for the Zipf distribution. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2140 |
* \return A floating point random value. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2141 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2142 |
* Note that antithetic values are being generated if m_isAntithetic |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2143 |
* is equal to true. If \f$u\f$ is a uniform variable over [0,1] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2144 |
* and \f$x\f$ is a value that would be returned normally, then |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2145 |
* \f$(1 - u\f$) is the distance that \f$u\f$ would be from \f$1\f$. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2146 |
* The value returned in the antithetic case, \f$x'\f$, uses (1-u), |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2147 |
* which is the distance \f$u\f$ is from the 1. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2148 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2149 |
double GetValue (uint32_t n, double alpha); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2150 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2151 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2152 |
* \brief Returns a random unsigned integer from a Zipf distribution with the specified n and alpha. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2153 |
* \param n N value for the Zipf distribution. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2154 |
* \param alpha Alpha value for the Zipf distribution. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2155 |
* \return A random unsigned integer value. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2156 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2157 |
* Note that antithetic values are being generated if m_isAntithetic |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2158 |
* is equal to true. If \f$u\f$ is a uniform variable over [0,1] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2159 |
* and \f$x\f$ is a value that would be returned normally, then |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2160 |
* \f$(1 - u\f$) is the distance that \f$u\f$ would be from \f$1\f$. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2161 |
* The value returned in the antithetic case, \f$x'\f$, uses (1-u), |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2162 |
* which is the distance \f$u\f$ is from the 1. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2163 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2164 |
uint32_t GetInteger (uint32_t n, uint32_t alpha); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2165 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2166 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2167 |
* \brief Returns a random double from a Zipf distribution with the current n and alpha. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2168 |
* \return A floating point random value. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2169 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2170 |
* Note that antithetic values are being generated if m_isAntithetic |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2171 |
* is equal to true. If \f$u\f$ is a uniform variable over [0,1] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2172 |
* and \f$x\f$ is a value that would be returned normally, then |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2173 |
* \f$(1 - u\f$) is the distance that \f$u\f$ would be from \f$1\f$. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2174 |
* The value returned in the antithetic case, \f$x'\f$, uses (1-u), |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2175 |
* which is the distance \f$u\f$ is from the 1. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2176 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2177 |
* Note that we have to re-implement this method here because the method is |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2178 |
* overloaded above for the two-argument variant and the c++ name resolution |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2179 |
* rules don't work well with overloads split between parent and child |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2180 |
* classes. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2181 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2182 |
virtual double GetValue (void); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2183 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2184 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2185 |
* \brief Returns a random unsigned integer from a Zipf distribution with the current n and alpha. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2186 |
* \return A random unsigned integer value. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2187 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2188 |
* Note that antithetic values are being generated if m_isAntithetic |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2189 |
* is equal to true. If \f$u\f$ is a uniform variable over [0,1] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2190 |
* and \f$x\f$ is a value that would be returned normally, then |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2191 |
* \f$(1 - u\f$) is the distance that \f$u\f$ would be from \f$1\f$. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2192 |
* The value returned in the antithetic case, \f$x'\f$, uses (1-u), |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2193 |
* which is the distance \f$u\f$ is from the 1. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2194 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2195 |
virtual uint32_t GetInteger (void); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2196 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2197 |
private: |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2198 |
/** The n value for the Zipf distribution returned by this RNG stream. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2199 |
uint32_t m_n; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2200 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2201 |
/** The alpha value for the Zipf distribution returned by this RNG stream. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2202 |
double m_alpha; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2203 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2204 |
/** The normalization constant. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2205 |
double m_c; |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2206 |
|
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2207 |
}; // class ZipfRandomVariable |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2208 |
|
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2209 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2210 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2211 |
* \ingroup randomvariable |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2212 |
* \brief The zeta distribution Random Number Generator (RNG) that |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2213 |
* allows stream numbers to be set deterministically. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2214 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2215 |
* This class supports the creation of objects that return random numbers |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2216 |
* from a fixed zeta distribution. It also supports the generation of |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2217 |
* single random numbers from various zeta distributions. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2218 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2219 |
* The Zeta distribution is closely related to Zipf distribution when |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2220 |
* N goes to infinity. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2221 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2222 |
* Zeta distribution has one parameter, alpha, \f$ \alpha > 1 \f$ (real). |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2223 |
* Probability Mass Function is \f$ f(k; \alpha) = k^{-\alpha}/\zeta(\alpha) \f$ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2224 |
* where \f$ \zeta(\alpha) \f$ is the Riemann zeta function ( \f$ \sum_{n=1}^\infty n^{-\alpha} ) \f$ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2225 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2226 |
* Here is an example of how to use this class: |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2227 |
* \code |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2228 |
* double alpha = 2.0; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2229 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2230 |
* Ptr<ZetaRandomVariable> x = CreateObject<ZetaRandomVariable> (); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2231 |
* x->SetAttribute ("Alpha", DoubleValue (alpha)); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2232 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2233 |
* // The expected value for the mean of the values returned by a |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2234 |
* // zetaly distributed random variable is equal to |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2235 |
* // |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2236 |
* // zeta(alpha - 1) |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2237 |
* // E[value] = --------------- for alpha > 2 , |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2238 |
* // zeta(alpha) |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2239 |
* // |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2240 |
* // where zeta(alpha) is the Riemann zeta function. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2241 |
* // |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2242 |
* // There are no simple analytic forms for the Riemann zeta |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2243 |
* // function, which is the reason the known mean of the values |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2244 |
* // cannot be calculated in this example. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2245 |
* // |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2246 |
* double value = x->GetValue (); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2247 |
* \endcode |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2248 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2249 |
class ZetaRandomVariable : public RandomVariableStream |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2250 |
{ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2251 |
public: |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2252 |
/** |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2253 |
* \brief Register this type. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2254 |
* \return The object TypeId. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2255 |
*/ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2256 |
static TypeId GetTypeId (void); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2257 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2258 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2259 |
* \brief Creates a zeta distribution RNG with the default value for |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2260 |
* alpha. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2261 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2262 |
ZetaRandomVariable (); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2263 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2264 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2265 |
* \brief Returns the alpha value for the zeta distribution returned by this RNG stream. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2266 |
* \return The alpha value for the zeta distribution returned by this RNG stream. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2267 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2268 |
double GetAlpha (void) const; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2269 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2270 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2271 |
* \brief Returns a random double from a zeta distribution with the specified alpha. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2272 |
* \param alpha Alpha value for the zeta distribution. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2273 |
* \return A floating point random value. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2274 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2275 |
* Note that antithetic values are being generated if m_isAntithetic |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2276 |
* is equal to true. If \f$u\f$ is a uniform variable over [0,1] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2277 |
* and \f$x\f$ is a value that would be returned normally, then |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2278 |
* \f$(1 - u\f$) is the distance that \f$u\f$ would be from \f$1\f$. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2279 |
* The value returned in the antithetic case, \f$x'\f$, uses (1-u), |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2280 |
* which is the distance \f$u\f$ is from the 1. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2281 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2282 |
double GetValue (double alpha); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2283 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2284 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2285 |
* \brief Returns a random unsigned integer from a zeta distribution with the specified alpha. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2286 |
* \param alpha Alpha value for the zeta distribution. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2287 |
* \return A random unsigned integer value. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2288 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2289 |
* Note that antithetic values are being generated if m_isAntithetic |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2290 |
* is equal to true. If \f$u\f$ is a uniform variable over [0,1] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2291 |
* and \f$x\f$ is a value that would be returned normally, then |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2292 |
* \f$(1 - u\f$) is the distance that \f$u\f$ would be from \f$1\f$. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2293 |
* The value returned in the antithetic case, \f$x'\f$, uses (1-u), |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2294 |
* which is the distance \f$u\f$ is from the 1. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2295 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2296 |
uint32_t GetInteger (uint32_t alpha); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2297 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2298 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2299 |
* \brief Returns a random double from a zeta distribution with the current alpha. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2300 |
* \return A floating point random value. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2301 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2302 |
* Note that antithetic values are being generated if m_isAntithetic |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2303 |
* is equal to true. If \f$u\f$ is a uniform variable over [0,1] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2304 |
* and \f$x\f$ is a value that would be returned normally, then |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2305 |
* \f$(1 - u\f$) is the distance that \f$u\f$ would be from \f$1\f$. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2306 |
* The value returned in the antithetic case, \f$x'\f$, uses (1-u), |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2307 |
* which is the distance \f$u\f$ is from the 1. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2308 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2309 |
* Note that we have to re-implement this method here because the method is |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2310 |
* overloaded above for the two-argument variant and the c++ name resolution |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2311 |
* rules don't work well with overloads split between parent and child |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2312 |
* classes. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2313 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2314 |
virtual double GetValue (void); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2315 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2316 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2317 |
* \brief Returns a random unsigned integer from a zeta distribution with the current alpha. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2318 |
* \return A random unsigned integer value. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2319 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2320 |
* Note that antithetic values are being generated if m_isAntithetic |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2321 |
* is equal to true. If \f$u\f$ is a uniform variable over [0,1] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2322 |
* and \f$x\f$ is a value that would be returned normally, then |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2323 |
* \f$(1 - u\f$) is the distance that \f$u\f$ would be from \f$1\f$. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2324 |
* The value returned in the antithetic case, \f$x'\f$, uses (1-u), |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2325 |
* which is the distance \f$u\f$ is from the 1. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2326 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2327 |
virtual uint32_t GetInteger (void); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2328 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2329 |
private: |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2330 |
/** The alpha value for the zeta distribution returned by this RNG stream. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2331 |
double m_alpha; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2332 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2333 |
/** Just for calculus simplifications. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2334 |
double m_b; |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2335 |
|
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2336 |
}; // class ZetaRandomVariable |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2337 |
|
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2338 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2339 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2340 |
* \ingroup randomvariable |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2341 |
* \brief The Random Number Generator (RNG) that returns a predetermined sequence. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2342 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2343 |
* Defines a random variable that has a specified, predetermined |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2344 |
* sequence. This would be useful when trying to force the RNG to |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2345 |
* return a known sequence, perhaps to compare ns-3 to some other |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2346 |
* simulator |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2347 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2348 |
* Creates a generator that returns successive elements of the values |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2349 |
* array on successive calls to RandomVariableStream::GetValue. Note |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2350 |
* that the values in the array are copied and stored by the generator |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2351 |
* (deep-copy). Also note that the sequence repeats if more values |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2352 |
* are requested than are present in the array. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2353 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2354 |
* Here is an example of how to use this class: |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2355 |
* \code |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2356 |
* Ptr<DeterministicRandomVariable> s = CreateObject<DeterministicRandomVariable> (); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2357 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2358 |
* // The following array should give the sequence |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2359 |
* // |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2360 |
* // 4, 4, 7, 7, 10, 10 . |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2361 |
* // |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2362 |
* double array [] = { 4, 4, 7, 7, 10, 10}; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2363 |
* uint64_t count = 6; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2364 |
* s->SetValueArray (array, count); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2365 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2366 |
* double value = x->GetValue (); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2367 |
* \endcode |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2368 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2369 |
class DeterministicRandomVariable : public RandomVariableStream |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2370 |
{ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2371 |
public: |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2372 |
/** |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2373 |
* \brief Register this type. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2374 |
* \return The object TypeId. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2375 |
*/ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2376 |
static TypeId GetTypeId (void); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2377 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2378 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2379 |
* \brief Creates a deterministic RNG that will have a predetermined |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2380 |
* sequence of values. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2381 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2382 |
DeterministicRandomVariable (); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2383 |
virtual ~DeterministicRandomVariable (); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2384 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2385 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2386 |
* \brief Sets the array of values that holds the predetermined sequence. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2387 |
* \param values Array of random values to return in sequence. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2388 |
* \param length Number of values in the array. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2389 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2390 |
* Note that the values in the array are copied and stored |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2391 |
* (deep-copy). |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2392 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2393 |
void SetValueArray (double* values, uint64_t length); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2394 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2395 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2396 |
* \brief Returns the next value in the sequence. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2397 |
* \return The floating point next value in the sequence. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2398 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2399 |
virtual double GetValue (void); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2400 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2401 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2402 |
* \brief Returns the next value in the sequence. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2403 |
* \return The integer next value in the sequence. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2404 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2405 |
virtual uint32_t GetInteger (void); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2406 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2407 |
private: |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2408 |
/** Position in the array of values. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2409 |
uint64_t m_count; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2410 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2411 |
/** Position of the next value in the array of values. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2412 |
uint64_t m_next; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2413 |
|
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2414 |
/** Array of values to return in sequence. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2415 |
double* m_data; |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2416 |
|
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2417 |
}; // class DeterministicRandomVariable |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2418 |
|
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2419 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2420 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2421 |
* \ingroup randomvariable |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2422 |
* \brief The Random Number Generator (RNG) that has a specified empirical distribution. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2423 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2424 |
* Defines a random variable that has a specified, empirical |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2425 |
* distribution. The distribution is specified by a |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2426 |
* series of calls to the CDF member function, specifying a |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2427 |
* value and the probability that the function value is less than |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2428 |
* the specified value. When values are requested, |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2429 |
* a uniform random variable is used to select a probability, |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2430 |
* and the return value is interpreted linearly between the |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2431 |
* two appropriate points in the CDF. The method is known |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2432 |
* as inverse transform sampling: |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2433 |
* (http://en.wikipedia.org/wiki/Inverse_transform_sampling). |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2434 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2435 |
* Here is an example of how to use this class: |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2436 |
* \code |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2437 |
* // Create the RNG with a uniform distribution between 0 and 10. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2438 |
* Ptr<EmpiricalRandomVariable> x = CreateObject<EmpiricalRandomVariable> (); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2439 |
* x->CDF ( 0.0, 0.0); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2440 |
* x->CDF ( 5.0, 0.5); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2441 |
* x->CDF (10.0, 1.0); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2442 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2443 |
* // The expected value for the mean of the values returned by this |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2444 |
* // empirical distribution is the midpoint of the distribution |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2445 |
* // |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2446 |
* // E[value] = 5 . |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2447 |
* // |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2448 |
* double value = x->GetValue (); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2449 |
* \endcode |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2450 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2451 |
class EmpiricalRandomVariable : public RandomVariableStream |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2452 |
{ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2453 |
public: |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2454 |
/** |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2455 |
* \brief Register this type. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2456 |
* \return The object TypeId. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2457 |
*/ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2458 |
static TypeId GetTypeId (void); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2459 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2460 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2461 |
* \brief Creates an empirical RNG that has a specified, empirical |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2462 |
* distribution. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2463 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2464 |
EmpiricalRandomVariable (); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2465 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2466 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2467 |
* \brief Specifies a point in the empirical distribution |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2468 |
* \param v The function value for this point |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2469 |
* \param c Probability that the function is less than or equal to v |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2470 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2471 |
void CDF (double v, double c); // Value, prob <= Value |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2472 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2473 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2474 |
* \brief Returns the next value in the empirical distribution. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2475 |
* \return The floating point next value in the empirical distribution. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2476 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2477 |
* Note that antithetic values are being generated if m_isAntithetic |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2478 |
* is equal to true. If \f$u\f$ is a uniform variable over [0,1] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2479 |
* and \f$x\f$ is a value that would be returned normally, then |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2480 |
* \f$(1 - u\f$) is the distance that \f$u\f$ would be from \f$1\f$. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2481 |
* The value returned in the antithetic case, \f$x'\f$, uses (1-u), |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2482 |
* which is the distance \f$u\f$ is from the 1. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2483 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2484 |
virtual double GetValue (void); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2485 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2486 |
/** |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2487 |
* \brief Returns the next value in the empirical distribution. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2488 |
* \return The integer next value in the empirical distribution. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2489 |
* |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2490 |
* Note that antithetic values are being generated if m_isAntithetic |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2491 |
* is equal to true. If \f$u\f$ is a uniform variable over [0,1] |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2492 |
* and \f$x\f$ is a value that would be returned normally, then |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2493 |
* \f$(1 - u\f$) is the distance that \f$u\f$ would be from \f$1\f$. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2494 |
* The value returned in the antithetic case, \f$x'\f$, uses (1-u), |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2495 |
* which is the distance \f$u\f$ is from the 1. |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2496 |
*/ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2497 |
virtual uint32_t GetInteger (void); |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2498 |
|
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2499 |
private: |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2500 |
/** Helper to hold one point of the CDF. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2501 |
class ValueCDF |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2502 |
{ |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2503 |
public: |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2504 |
/** Constructor. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2505 |
ValueCDF (); |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2506 |
/** |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2507 |
* Construct from values. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2508 |
* |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2509 |
* \param [in] v The argumetn value. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2510 |
* \param [in] c The CDF at the argument value \p v. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2511 |
*/ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2512 |
ValueCDF (double v, double c); |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2513 |
/** |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2514 |
* Copy constructor. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2515 |
* |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2516 |
* \param [in] c The other ValueCDF. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2517 |
*/ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2518 |
ValueCDF (const ValueCDF& c); |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2519 |
|
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2520 |
/** The argument value. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2521 |
double value; |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2522 |
/** The CDF at \p value. */ |
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2523 |
double cdf; |
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2524 |
}; |
11531
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2525 |
/** |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2526 |
* Check that the CDF is valid. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2527 |
* |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2528 |
* A valid CDF has |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2529 |
* |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2530 |
* - Strictly increasing arguments, and |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2531 |
* - Strictly increasing CDF. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2532 |
* |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2533 |
* It is a fatal error to fail validation. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2534 |
*/ |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2535 |
virtual void Validate (); |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2536 |
/** |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2537 |
* Linear nterpolation between two points on the CDF to estimate |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2538 |
* the value at \p r. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2539 |
* |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2540 |
* \param [in] c1 The first argument value. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2541 |
* \param [in] c2 The secong argument value. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2542 |
* \param [in] v1 The first CDF value. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2543 |
* \param [in] v2 The secong CDF value. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2544 |
* \param [in] r The argument value to interpolate to. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2545 |
* \returns The interpolated CDF at \p r. |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2546 |
*/ |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2547 |
virtual double Interpolate (double c1, double c2, |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2548 |
double v1, double v2, double r); |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2549 |
|
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2550 |
/** \c true once the CDF has been validated. */ |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2551 |
bool validated; |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2552 |
/** The vector of CDF points. */ |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2553 |
std::vector<ValueCDF> emp; |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2554 |
|
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2555 |
}; // class EmpiricalRandomVariable |
5d6b3f94ebf3
[Doxygen] Remaining in core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
2556 |
|
8872
32d1fa5dfb9f
Port remaining RandomVariable implementations to RandomVariableStream
Mitch Watrous <watrous@u.washington.edu>
parents:
8871
diff
changeset
|
2557 |
|
8871
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
2558 |
} // namespace ns3 |
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
2559 |
|
60846d2741c0
initial patch to fix rng variability
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
diff
changeset
|
2560 |
#endif /* RANDOM_VARIABLE_STREAM_H */ |