author | Raj Bhattacharjea <raj.b@gatech.edu> |
Thu, 03 May 2007 14:19:33 -0400 | |
changeset 442 | 96d3e7dc8bb2 |
parent 438 | 515bb5663cf3 |
child 592 | f7e4beac3e31 |
permissions | -rw-r--r-- |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
2 |
// |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
3 |
// Copyright (c) 2006 Georgia Tech Research Corporation |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
4 |
// |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
5 |
// This program is free software; you can redistribute it and/or modify |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
6 |
// it under the terms of the GNU General Public License version 2 as |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
7 |
// published by the Free Software Foundation; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
8 |
// |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
9 |
// This program is distributed in the hope that it will be useful, |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
12 |
// GNU General Public License for more details. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
13 |
// |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
14 |
// You should have received a copy of the GNU General Public License |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
15 |
// along with this program; if not, write to the Free Software |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
16 |
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
17 |
// |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
18 |
// Author: Rajib Bhattacharjea<raj.b@gatech.edu> |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
19 |
// |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
20 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
21 |
#ifndef __random_variable_h__ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
22 |
#define __random_variable_h__ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
23 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
24 |
#include <vector> |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
25 |
#include <algorithm> |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
26 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
27 |
|
396
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
28 |
/** |
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
29 |
* \defgroup randomvariable Random Variable Distributions |
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
30 |
* |
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
31 |
*/ |
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
32 |
|
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
33 |
namespace ns3{ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
34 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
35 |
class RngStream; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
36 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
37 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
38 |
* \brief The basic RNG for NS-3. |
396
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
39 |
* \ingroup randomvariable |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
40 |
* |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
41 |
* Note: The underlying random number generation method used |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
42 |
* by NS-3 is the RngStream code by Pierre L'Ecuyer at |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
43 |
* the University of Montreal. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
44 |
* |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
45 |
* NS-3 has a rich set of random number generators. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
46 |
* Class RandomVariable defines the base class functionalty |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
47 |
* required for all random number generators. By default, the underlying |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
48 |
* generator is seeded with the time of day, and then deterministically |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
49 |
* creates a sequence of seeds for each subsequent generator that is created. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
50 |
* The rest of the documentation outlines how to change this behavior. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
51 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
52 |
class RandomVariable { |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
53 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
54 |
public: |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
55 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
56 |
* \brief Constructor for a random number generator with a random seed. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
57 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
58 |
RandomVariable(); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
59 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
60 |
/** |
360
7bffd987426c
Fixed major memory bug and docs in RandomVariable
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
346
diff
changeset
|
61 |
* \brief Copy constructor |
7bffd987426c
Fixed major memory bug and docs in RandomVariable
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
346
diff
changeset
|
62 |
*/ |
7bffd987426c
Fixed major memory bug and docs in RandomVariable
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
346
diff
changeset
|
63 |
RandomVariable(const RandomVariable&); |
7bffd987426c
Fixed major memory bug and docs in RandomVariable
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
346
diff
changeset
|
64 |
|
7bffd987426c
Fixed major memory bug and docs in RandomVariable
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
346
diff
changeset
|
65 |
/** |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
66 |
* \brief Destructor for a random number generator with a random seed. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
67 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
68 |
virtual ~RandomVariable(); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
69 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
70 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
71 |
* \brief Returns a random double from the underlying distribution |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
72 |
* \return A floating point random value |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
73 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
74 |
virtual double GetValue() = 0; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
75 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
76 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
77 |
* \brief Returns a random integer integer from the underlying distribution |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
78 |
* \return Integer cast of ::GetValue() |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
79 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
80 |
virtual uint32_t GetIntValue(); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
81 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
82 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
83 |
* \return A copy of this object |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
84 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
85 |
virtual RandomVariable* Copy() const = 0; |
364
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
86 |
|
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
87 |
/** |
364
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
88 |
* \brief Get the internal state of the RNG |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
89 |
* |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
90 |
* This function is for power users who understand the inner workings |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
91 |
* of the underlying RngStream method used. It returns the internal |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
92 |
* state of the RNG via the input parameter. |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
93 |
* \param seed Output parameter; gets overwritten with the internal state of |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
94 |
* of the RNG. |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
95 |
*/ |
364
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
96 |
virtual void GetSeed(uint32_t seed[6]); |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
97 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
98 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
99 |
* \brief Set seeding behavior |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
100 |
* |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
101 |
* Specify whether the POSIX device /dev/random is to |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
102 |
* be used for seeding. When this is used, the underlying |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
103 |
* generator is seeded with data from /dev/random instead of |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
104 |
* being seeded based upon the time of day. For this to be effective, |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
105 |
* it must be called before the creation of the first instance of a |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
106 |
* RandomVariable or subclass. Example: |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
107 |
* \code |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
108 |
* RandomVariable::UseDevRandom(); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
109 |
* UniformVariable x(2,3); //these are seeded randomly |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
110 |
* ExponentialVariable y(120); //etc |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
111 |
* \endcode |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
112 |
* \param udr True if /dev/random desired. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
113 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
114 |
static void UseDevRandom(bool udr = true); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
115 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
116 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
117 |
* \brief Use the global seed to force precisely reproducible results. |
360
7bffd987426c
Fixed major memory bug and docs in RandomVariable
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
346
diff
changeset
|
118 |
* |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
119 |
* It is often desirable to create a simulation that uses random |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
120 |
* numbers, while at the same time is completely reproducible. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
121 |
* Specifying this set of six random seeds initializes the |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
122 |
* random number generator with the specified seed. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
123 |
* Once this is set, all generators will produce fixed output |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
124 |
* from run to run. This is because each time a new generator is created, |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
125 |
* the underlying RngStream deterministically creates a new seed based upon |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
126 |
* the old one, hence a "stream" of RNGs. Example: |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
127 |
* \code |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
128 |
* RandomVariable::UseGlobalSeed(...); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
129 |
* UniformVariable x(2,3); //these will give the same output everytime |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
130 |
* ExponentialVariable y(120); //as long as the seed stays the same |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
131 |
* \endcode |
423
76a580dfb0f7
Removed the unnecessary Seed classes
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
420
diff
changeset
|
132 |
* \param s0 |
76a580dfb0f7
Removed the unnecessary Seed classes
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
420
diff
changeset
|
133 |
* \param s1 |
76a580dfb0f7
Removed the unnecessary Seed classes
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
420
diff
changeset
|
134 |
* \param s2 |
76a580dfb0f7
Removed the unnecessary Seed classes
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
420
diff
changeset
|
135 |
* \param s3 |
76a580dfb0f7
Removed the unnecessary Seed classes
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
420
diff
changeset
|
136 |
* \param s4 |
76a580dfb0f7
Removed the unnecessary Seed classes
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
420
diff
changeset
|
137 |
* \param s5 |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
138 |
* \return True if seed is valid. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
139 |
*/ |
423
76a580dfb0f7
Removed the unnecessary Seed classes
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
420
diff
changeset
|
140 |
static void UseGlobalSeed(uint32_t s0, uint32_t s1, uint32_t s2, |
76a580dfb0f7
Removed the unnecessary Seed classes
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
420
diff
changeset
|
141 |
uint32_t s3, uint32_t s4, uint32_t s5); |
364
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
142 |
|
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
143 |
/** |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
144 |
* \brief Set the run number of this simulation |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
145 |
* |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
146 |
* These RNGs have the ability to give independent sets of trials for a fixed |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
147 |
* global seed. For example, suppose one sets up a simulation with |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
148 |
* RandomVariables with a given global seed. Suppose the user wanted to |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
149 |
* retry the same simulation with different random values for validity, |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
150 |
* statistical rigor, etc. The user could either change the global seed and |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
151 |
* re-run the simulation, or could use this facility to increment all of the |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
152 |
* RNGs to a next substream state. This predictably advances the internal |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
153 |
* state of all RandomVariables n steps. This should be called immediately |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
154 |
* after the global seed is set, and before the creation of any |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
155 |
* RandomVariables. For example: |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
156 |
* \code |
423
76a580dfb0f7
Removed the unnecessary Seed classes
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
420
diff
changeset
|
157 |
* RandomVariable::UseGlobalSeed(1,2,3,4,5,6); |
364
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
158 |
* int N = atol(argv[1]); //read in run number from command line |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
159 |
* RandomVariable::SetRunNumber(N); |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
160 |
* UniformVariable x(0,10); |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
161 |
* ExponentialVariable y(2902); |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
162 |
* \endcode |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
163 |
* In this example, N could successivly be equal to 1,2,3, etc. and the user |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
164 |
* would continue to get independent runs out of the single simulation. For |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
165 |
* this simple example, the following might work: |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
166 |
* \code |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
167 |
* ./simulation 0 |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
168 |
* ...Results for run 0:... |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
169 |
* |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
170 |
* ./simulation 1 |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
171 |
* ...Results for run 1:... |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
172 |
* \endcode |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
173 |
*/ |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
174 |
static void SetRunNumber(uint32_t n); |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
175 |
private: |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
176 |
static void Initialize(); // Initialize the RNG system |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
177 |
static void GetRandomSeeds(uint32_t seeds[6]); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
178 |
private: |
364
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
179 |
static bool initialized; // True if package seed is set |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
180 |
static bool useDevRandom; // True if using /dev/random desired |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
181 |
static bool globalSeedSet; // True if global seed has been specified |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
182 |
static int devRandom; // File handle for /dev/random |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
183 |
static uint32_t globalSeed[6]; // The global seed to use |
364
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
184 |
static uint32_t runNumber; |
442
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
185 |
friend class RandomVariableInitializer; |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
186 |
protected: |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
187 |
static unsigned long heuristic_sequence; |
442
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
188 |
static RngStream* m_static_generator; |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
189 |
RngStream* m_generator; //underlying generator being wrapped |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
190 |
}; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
191 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
192 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
193 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
194 |
* \brief The uniform distribution RNG for NS-3. |
396
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
195 |
* \ingroup randomvariable |
442
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
196 |
* This class supports the creation of objects that return random numbers |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
197 |
* from a fixed uniform distribution. It also supports the generation of |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
198 |
* single random numbers from various uniform distributions. |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
199 |
* \code |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
200 |
* UniformVariable x(0,10); |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
201 |
* x.GetValue(); //will always return numbers [0,10] |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
202 |
* UniformVariable::GetSingleValue(100,1000); //returns a value [100,1000] |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
203 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
204 |
class UniformVariable : public RandomVariable { |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
205 |
public: |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
206 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
207 |
* Creates a uniform random number generator in the |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
208 |
* range [0.0 .. 1.0) |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
209 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
210 |
UniformVariable(); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
211 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
212 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
213 |
* Creates a uniform random number generator with the specified range |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
214 |
* \param s Low end of the range |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
215 |
* \param l High end of the range |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
216 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
217 |
UniformVariable(double s, double l); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
218 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
219 |
UniformVariable(const UniformVariable& c); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
220 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
221 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
222 |
* \return A value between low and high values specified by the constructor |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
223 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
224 |
virtual double GetValue(); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
225 |
virtual RandomVariable* Copy() const; |
442
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
226 |
public: |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
227 |
/** |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
228 |
* \param s Low end of the range |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
229 |
* \param l High end of the range |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
230 |
* \return A uniformly distributed random number between s and l |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
231 |
*/ |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
232 |
static double GetSingleValue(double s, double l); |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
233 |
private: |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
234 |
double m_min; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
235 |
double m_max; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
236 |
}; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
237 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
238 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
239 |
* \brief A random variable that returns a constant |
396
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
240 |
* \ingroup randomvariable |
360
7bffd987426c
Fixed major memory bug and docs in RandomVariable
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
346
diff
changeset
|
241 |
* |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
242 |
* Class ConstantVariable defines a random number generator that |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
243 |
* returns the same value every sample. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
244 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
245 |
class ConstantVariable : public RandomVariable { |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
246 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
247 |
public: |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
248 |
/** |
360
7bffd987426c
Fixed major memory bug and docs in RandomVariable
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
346
diff
changeset
|
249 |
* Construct a ConstantVariable RNG that returns zero every sample |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
250 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
251 |
ConstantVariable(); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
252 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
253 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
254 |
* Construct a ConstantVariable RNG that returns the specified value |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
255 |
* every sample. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
256 |
* \param c Unchanging value for this RNG. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
257 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
258 |
ConstantVariable(double c); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
259 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
260 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
261 |
ConstantVariable(const ConstantVariable& c) ; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
262 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
263 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
264 |
* \brief Specify a new constant RNG for this generator. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
265 |
* \param c New constant value for this RNG. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
266 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
267 |
void NewConstant(double c); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
268 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
269 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
270 |
* \return The constant value specified |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
271 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
272 |
virtual double GetValue(); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
273 |
virtual uint32_t GetIntValue(); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
274 |
virtual RandomVariable* Copy() const; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
275 |
private: |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
276 |
double m_const; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
277 |
}; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
278 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
279 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
280 |
* \brief Return a sequential list of values |
396
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
281 |
* \ingroup randomvariable |
360
7bffd987426c
Fixed major memory bug and docs in RandomVariable
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
346
diff
changeset
|
282 |
* |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
283 |
* Class SequentialVariable defines a random number generator that |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
284 |
* returns a sequential sequence. The sequence monotonically |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
285 |
* increases for a period, then wraps around to the low value |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
286 |
* and begins monotonicaly increasing again. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
287 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
288 |
class SequentialVariable : public RandomVariable { |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
289 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
290 |
public: |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
291 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
292 |
* \brief Constructor for the SequentialVariable RNG. |
360
7bffd987426c
Fixed major memory bug and docs in RandomVariable
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
346
diff
changeset
|
293 |
* |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
294 |
* The four parameters define the sequence. For example |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
295 |
* SequentialVariable(0,5,1,2) creates a RNG that has the sequence |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
296 |
* 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 0, 0 ... |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
297 |
* \param f First value of the sequence. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
298 |
* \param l One more than the last value of the sequence. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
299 |
* \param i Increment between sequence values |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
300 |
* \param c Number of times each member of the sequence is repeated |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
301 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
302 |
SequentialVariable(double f, double l, double i = 1, uint32_t c = 1); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
303 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
304 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
305 |
* \brief Constructor for the SequentialVariable RNG. |
360
7bffd987426c
Fixed major memory bug and docs in RandomVariable
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
346
diff
changeset
|
306 |
* |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
307 |
* Differs from the first only in that the increment parameter is a |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
308 |
* random variable |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
309 |
* \param f First value of the sequence. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
310 |
* \param l One more than the last value of the sequence. |
360
7bffd987426c
Fixed major memory bug and docs in RandomVariable
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
346
diff
changeset
|
311 |
* \param i Reference to a RandomVariable for the sequence increment |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
312 |
* \param c Number of times each member of the sequence is repeated |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
313 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
314 |
SequentialVariable(double f, double l, const RandomVariable& i, uint32_t c = 1); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
315 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
316 |
SequentialVariable(const SequentialVariable& c); |
360
7bffd987426c
Fixed major memory bug and docs in RandomVariable
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
346
diff
changeset
|
317 |
|
7bffd987426c
Fixed major memory bug and docs in RandomVariable
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
346
diff
changeset
|
318 |
~SequentialVariable(); |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
319 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
320 |
* \return The next value in the Sequence |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
321 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
322 |
virtual double GetValue(); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
323 |
virtual RandomVariable* Copy() const; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
324 |
private: |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
325 |
double m_min; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
326 |
double m_max; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
327 |
RandomVariable* m_increment; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
328 |
uint32_t m_consecutive; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
329 |
double m_current; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
330 |
uint32_t m_currentConsecutive; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
331 |
}; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
332 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
333 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
334 |
* \brief Exponentially Distributed random var |
396
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
335 |
* \ingroup randomvariable |
442
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
336 |
* This class supports the creation of objects that return random numbers |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
337 |
* from a fixed exponential distribution. It also supports the generation of |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
338 |
* single random numbers from various exponential distributions. |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
339 |
* \code |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
340 |
* ExponentialVariable x(3.14); |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
341 |
* x.GetValue(); //will always return with mean 3.14 |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
342 |
* ExponentialVariable::GetSingleValue(20.1); //returns with mean 20.1 |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
343 |
* ExponentialVariable::GetSingleValue(108); //returns with mean 108 |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
344 |
* \endcode |
360
7bffd987426c
Fixed major memory bug and docs in RandomVariable
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
346
diff
changeset
|
345 |
* |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
346 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
347 |
class ExponentialVariable : public RandomVariable { |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
348 |
public: |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
349 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
350 |
* Constructs an exponential random variable with a mean |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
351 |
* value of 1.0. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
352 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
353 |
ExponentialVariable(); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
354 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
355 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
356 |
* \brief Constructs an exponential random variable with a specified mean |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
357 |
* \param m Mean value for the random variable |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
358 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
359 |
explicit ExponentialVariable(double m); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
360 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
361 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
362 |
* \brief Constructs an exponential random variable with spefified |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
363 |
* \brief mean and upper limit. |
360
7bffd987426c
Fixed major memory bug and docs in RandomVariable
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
346
diff
changeset
|
364 |
* |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
365 |
* Since exponential distributions can theoretically return unbounded values, |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
366 |
* it is sometimes useful to specify a fixed upper limit. Note however when |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
367 |
* the upper limit is specified, the true mean of the distribution is |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
368 |
* slightly smaller than the mean value specified. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
369 |
* \param m Mean value of the random variable |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
370 |
* \param b Upper bound on returned values |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
371 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
372 |
ExponentialVariable(double m, double b); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
373 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
374 |
ExponentialVariable(const ExponentialVariable& c); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
375 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
376 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
377 |
* \return A random value from this exponential distribution |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
378 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
379 |
virtual double GetValue(); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
380 |
virtual RandomVariable* Copy() const; |
442
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
381 |
public: |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
382 |
/** |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
383 |
* \param m The mean of the distribution from which the return value is drawn |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
384 |
* \param b The upper bound value desired, beyond which values get clipped |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
385 |
* \return A random number from an exponential distribution with mean m |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
386 |
*/ |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
387 |
static double GetSingleValue(double m, double b=0); |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
388 |
private: |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
389 |
double m_mean; // Mean value of RV |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
390 |
double m_bound; // Upper bound on value (if non-zero) |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
391 |
}; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
392 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
393 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
394 |
* \brief ParetoVariable distributed random var |
396
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
395 |
* \ingroup randomvariable |
442
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
396 |
* This class supports the creation of objects that return random numbers |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
397 |
* from a fixed pareto distribution. It also supports the generation of |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
398 |
* single random numbers from various pareto distributions. |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
399 |
* \code |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
400 |
* ParetoVariable x(3.14); |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
401 |
* x.GetValue(); //will always return with mean 3.14 |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
402 |
* ParetoVariable::GetSingleValue(20.1); //returns with mean 20.1 |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
403 |
* ParetoVariable::GetSingleValue(108); //returns with mean 108 |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
404 |
* \endcode |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
405 |
*/ |
442
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
406 |
class ParetoVariable : public RandomVariable { |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
407 |
public: |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
408 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
409 |
* Constructs a pareto random variable with a mean of 1 and a shape |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
410 |
* parameter of 1.5 |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
411 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
412 |
ParetoVariable(); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
413 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
414 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
415 |
* Constructs a pareto random variable with specified mean and shape |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
416 |
* parameter of 1.5 |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
417 |
* \param m Mean value of the distribution |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
418 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
419 |
explicit ParetoVariable(double m); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
420 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
421 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
422 |
* Constructs a pareto random variable with the specified mean value and |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
423 |
* shape parameter. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
424 |
* \param m Mean value of the distribution |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
425 |
* \param s Shape parameter for the distribution |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
426 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
427 |
ParetoVariable(double m, double s); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
428 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
429 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
430 |
* \brief Constructs a pareto random variable with the specified mean |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
431 |
* \brief value, shape (alpha), and upper bound. |
442
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
432 |
* |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
433 |
* Since pareto distributions can theoretically return unbounded values, |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
434 |
* it is sometimes useful to specify a fixed upper limit. Note however |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
435 |
* when the upper limit is specified, the true mean of the distribution |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
436 |
* is slightly smaller than the mean value specified. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
437 |
* \param m Mean value |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
438 |
* \param s Shape parameter |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
439 |
* \param b Upper limit on returned values |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
440 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
441 |
ParetoVariable(double m, double s, double b); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
442 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
443 |
ParetoVariable(const ParetoVariable& c); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
444 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
445 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
446 |
* \return A random value from this Pareto distribution |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
447 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
448 |
virtual double GetValue(); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
449 |
virtual RandomVariable* Copy() const; |
442
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
450 |
public: |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
451 |
/** |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
452 |
* \param m The mean value of the distribution from which the return value |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
453 |
* is drawn. |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
454 |
* \param s The shape parameter of the distribution from which the return |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
455 |
* value is drawn. |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
456 |
* \param b The upper bound to which to restrict return values |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
457 |
* \return A random number from a Pareto distribution with mean m and shape |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
458 |
* parameter s. |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
459 |
*/ |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
460 |
static double GetSingleValue(double m, double s, double b=0); |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
461 |
private: |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
462 |
double m_mean; // Mean value of RV |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
463 |
double m_shape; // Shape parameter |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
464 |
double m_bound; // Upper bound on value (if non-zero) |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
465 |
}; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
466 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
467 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
468 |
* \brief WeibullVariable distributed random var |
396
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
469 |
* \ingroup randomvariable |
442
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
470 |
* This class supports the creation of objects that return random numbers |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
471 |
* from a fixed weibull distribution. It also supports the generation of |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
472 |
* single random numbers from various weibull distributions. |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
473 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
474 |
class WeibullVariable : public RandomVariable { |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
475 |
public: |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
476 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
477 |
* Constructs a weibull random variable with a mean |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
478 |
* value of 1.0 and a shape (alpha) parameter of 1 |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
479 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
480 |
WeibullVariable(); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
481 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
482 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
483 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
484 |
* Constructs a weibull random variable with the specified mean |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
485 |
* value and a shape (alpha) parameter of 1.5. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
486 |
* \param m mean value of the distribution |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
487 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
488 |
WeibullVariable(double m) ; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
489 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
490 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
491 |
* Constructs a weibull random variable with the specified mean |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
492 |
* value and a shape (alpha). |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
493 |
* \param m Mean value for the distribution. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
494 |
* \param s Shape (alpha) parameter for the distribution. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
495 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
496 |
WeibullVariable(double m, double s); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
497 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
498 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
499 |
* \brief Constructs a weibull random variable with the specified mean |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
500 |
* \brief value, shape (alpha), and upper bound. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
501 |
* Since WeibullVariable distributions can theoretically return unbounded values, |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
502 |
* it is sometimes usefull to specify a fixed upper limit. Note however |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
503 |
* that when the upper limit is specified, the true mean of the distribution |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
504 |
* is slightly smaller than the mean value specified. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
505 |
* \param m Mean value for the distribution. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
506 |
* \param s Shape (alpha) parameter for the distribution. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
507 |
* \param b Upper limit on returned values |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
508 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
509 |
WeibullVariable(double m, double s, double b); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
510 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
511 |
WeibullVariable(const WeibullVariable& c); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
512 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
513 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
514 |
* \return A random value from this Weibull distribution |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
515 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
516 |
virtual double GetValue(); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
517 |
virtual RandomVariable* Copy() const; |
442
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
518 |
public: |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
519 |
/** |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
520 |
* \param m Mean value for the distribution. |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
521 |
* \param s Shape (alpha) parameter for the distribution. |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
522 |
* \param b Upper limit on returned values |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
523 |
* \return Random number from a distribution specified by m,s, and b |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
524 |
*/ |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
525 |
static double GetSingleValue(double m, double s, double b=0); |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
526 |
private: |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
527 |
double m_mean; // Mean value of RV |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
528 |
double m_alpha; // Shape parameter |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
529 |
double m_bound; // Upper bound on value (if non-zero) |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
530 |
}; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
531 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
532 |
/** |
396
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
533 |
* \brief Class NormalVariable defines a random variable with a |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
534 |
* normal (Gaussian) distribution. |
442
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
535 |
* |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
536 |
* This class supports the creation of objects that return random numbers |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
537 |
* from a fixed normal distribution. It also supports the generation of |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
538 |
* single random numbers from various normal distributions. |
396
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
539 |
* \ingroup randomvariable |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
540 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
541 |
class NormalVariable : public RandomVariable { // Normally Distributed random var |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
542 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
543 |
public: |
420
32ebc6582692
Fixed NormalVariable::INFINITE_VALUE
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
397
diff
changeset
|
544 |
static const double INFINITE_VALUE; |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
545 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
546 |
* Constructs an normal random variable with a mean |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
547 |
* value of 0 and variance of 1. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
548 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
549 |
NormalVariable(); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
550 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
551 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
552 |
* \brief Construct a normal random variable with specified mean and variance |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
553 |
* \param m Mean value |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
554 |
* \param v Variance |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
555 |
* \param b Bound. The NormalVariable is bounded within +-bound. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
556 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
557 |
NormalVariable(double m, double v, double b = INFINITE_VALUE); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
558 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
559 |
NormalVariable(const NormalVariable& c); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
560 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
561 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
562 |
* \return A value from this normal distribution |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
563 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
564 |
virtual double GetValue(); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
565 |
virtual RandomVariable* Copy() const; |
442
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
566 |
public: |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
567 |
/** |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
568 |
* \param m Mean value |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
569 |
* \param v Variance |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
570 |
* \param b Bound. The NormalVariable is bounded within +-bound. |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
571 |
* \return A random number from a distribution specified by m,v, and b. |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
572 |
*/ |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
573 |
static double GetSingleValue(double m, double v, double b = INFINITE_VALUE); |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
574 |
private: |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
575 |
double m_mean; // Mean value of RV |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
576 |
double m_variance; // Mean value of RV |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
577 |
double m_bound; // Bound on value (absolute value) |
442
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
578 |
bool m_nextValid; // True if next valid |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
579 |
double m_next; // The algorithm produces two values at a time |
442
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
580 |
static bool m_static_nextValid; |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
581 |
static double m_static_next; |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
582 |
}; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
583 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
584 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
585 |
* \brief EmpiricalVariable distribution random var |
396
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
586 |
* \ingroup randomvariable |
360
7bffd987426c
Fixed major memory bug and docs in RandomVariable
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
346
diff
changeset
|
587 |
* |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
588 |
* Defines a random variable that has a specified, empirical |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
589 |
* distribution. The distribution is specified by a |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
590 |
* series of calls the the CDF member function, specifying a |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
591 |
* value and the probability that the function value is less than |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
592 |
* the specified value. When values are requested, |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
593 |
* a uniform random variable is used to select a probabililty, |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
594 |
* and the return value is interpreted linerarly between the |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
595 |
* two appropriate points in the CDF |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
596 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
597 |
class EmpiricalVariable : public RandomVariable { |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
598 |
public: |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
599 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
600 |
* Constructor for the EmpiricalVariable random variables. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
601 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
602 |
explicit EmpiricalVariable(); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
603 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
604 |
virtual ~EmpiricalVariable(); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
605 |
EmpiricalVariable(const EmpiricalVariable& c); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
606 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
607 |
* \return A value from this empirical distribution |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
608 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
609 |
virtual double GetValue(); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
610 |
virtual RandomVariable* Copy() const; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
611 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
612 |
* \brief Specifies a point in the empirical distribution |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
613 |
* \param v The function value for this point |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
614 |
* \param c Probability that the function is less than or equal to v |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
615 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
616 |
virtual void CDF(double v, double c); // Value, prob <= Value |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
617 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
618 |
private: |
397
507fb2381e5c
move ValueCDF class to private class member
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
396
diff
changeset
|
619 |
class ValueCDF { |
507fb2381e5c
move ValueCDF class to private class member
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
396
diff
changeset
|
620 |
public: |
507fb2381e5c
move ValueCDF class to private class member
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
396
diff
changeset
|
621 |
ValueCDF(); |
507fb2381e5c
move ValueCDF class to private class member
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
396
diff
changeset
|
622 |
ValueCDF(double v, double c); |
507fb2381e5c
move ValueCDF class to private class member
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
396
diff
changeset
|
623 |
ValueCDF(const ValueCDF& c); |
507fb2381e5c
move ValueCDF class to private class member
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
396
diff
changeset
|
624 |
double value; |
507fb2381e5c
move ValueCDF class to private class member
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
396
diff
changeset
|
625 |
double cdf; |
507fb2381e5c
move ValueCDF class to private class member
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
396
diff
changeset
|
626 |
}; |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
627 |
virtual void Validate(); // Insure non-decreasing emiprical values |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
628 |
virtual double Interpolate(double, double, double, double, double); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
629 |
bool validated; // True if non-decreasing validated |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
630 |
std::vector<ValueCDF> emp; // Empicical CDF |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
631 |
}; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
632 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
633 |
/** |
396
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
634 |
* \brief Integer-based empirical distribution |
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
635 |
* \ingroup randomvariable |
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
636 |
* |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
637 |
* Defines an empirical distribution where all values are integers. |
360
7bffd987426c
Fixed major memory bug and docs in RandomVariable
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
346
diff
changeset
|
638 |
* Indentical to EmpiricalVariable, but with slightly different |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
639 |
* interpolation between points. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
640 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
641 |
class IntEmpiricalVariable : public EmpiricalVariable { |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
642 |
public: |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
643 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
644 |
IntEmpiricalVariable(); |
360
7bffd987426c
Fixed major memory bug and docs in RandomVariable
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
346
diff
changeset
|
645 |
|
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
646 |
virtual RandomVariable* Copy() const; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
647 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
648 |
* \return An integer value from this empirical distribution |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
649 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
650 |
virtual uint32_t GetIntValue(); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
651 |
virtual double Interpolate(double, double, double, double, double); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
652 |
}; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
653 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
654 |
/** |
396
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
655 |
* \brief a non-random variable |
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
656 |
* \ingroup randomvariable |
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
657 |
* |
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
658 |
* Defines a random variable that has a specified, predetermined |
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
659 |
* sequence. This would be useful when trying to force |
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
660 |
* the RNG to return a known sequence, perhaps to |
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
661 |
* compare NS-3 to some other simulator |
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
662 |
*/ |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
663 |
class DeterministicVariable : public RandomVariable { |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
664 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
665 |
public: |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
666 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
667 |
* \brief Constructor |
360
7bffd987426c
Fixed major memory bug and docs in RandomVariable
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
346
diff
changeset
|
668 |
* |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
669 |
* Creates a generator that returns successive elements of the d array |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
670 |
* on successive calls to ::Value(). Note that the d pointer is copied |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
671 |
* for use by the generator (shallow-copy), not its contents, so the |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
672 |
* contents of the array d points to have to remain unchanged for the use |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
673 |
* of DeterministicVariable to be meaningful. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
674 |
* \param d Pointer to array of random values to return in sequence |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
675 |
* \param c Number of values in the array |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
676 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
677 |
explicit DeterministicVariable(double* d, uint32_t c); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
678 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
679 |
virtual ~DeterministicVariable(); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
680 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
681 |
* \return The next value in the deterministic sequence |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
682 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
683 |
virtual double GetValue(); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
684 |
virtual RandomVariable* Copy() const; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
685 |
private: |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
686 |
uint32_t count; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
687 |
uint32_t next; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
688 |
double* data; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
689 |
}; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
690 |
|
438
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
691 |
|
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
692 |
/** |
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
693 |
* \brief Log-normal Distributed random var |
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
694 |
* \ingroup randomvariable |
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
695 |
* LogNormalVariable defines a random variable with log-normal |
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
696 |
* distribution. If one takes the natural logarithm of random |
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
697 |
* variable following the log-normal distribution, the obtained values |
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
698 |
* follow a normal distribution. |
442
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
699 |
* This class supports the creation of objects that return random numbers |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
700 |
* from a fixed lognormal distribution. It also supports the generation of |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
701 |
* single random numbers from various lognormal distributions. |
438
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
702 |
*/ |
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
703 |
class LogNormalVariable : public RandomVariable { |
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
704 |
public: |
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
705 |
/** |
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
706 |
* \param mu Mean value of the underlying normal distribution. |
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
707 |
* \param sigma Standard deviation of the underlying normal distribution. |
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
708 |
* |
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
709 |
* Notice: the parameters mu and sigma are _not_ the mean and standard |
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
710 |
* deviation of the log-normal distribution. To obtain the |
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
711 |
* parameters mu and sigma for a given mean and standard deviation |
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
712 |
* of the log-normal distribution the following convertion can be |
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
713 |
* used: |
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
714 |
* \code |
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
715 |
* double tmp = log (1 + pow (stddev/mean, 2)); |
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
716 |
* double sigma = sqrt (tmp); |
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
717 |
* double mu = log (mean) - 0.5*tmp; |
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
718 |
* \endcode |
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
719 |
*/ |
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
720 |
LogNormalVariable (double mu, double sigma); |
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
721 |
|
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
722 |
/** |
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
723 |
* \return A random value from this distribution |
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
724 |
*/ |
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
725 |
virtual double GetValue (); |
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
726 |
virtual RandomVariable* Copy() const; |
442
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
727 |
public: |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
728 |
/** |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
729 |
* \param mu Mean value of the underlying normal distribution. |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
730 |
* \param sigma Standard deviation of the underlying normal distribution. |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
731 |
* \return A random number from the distribution specified by mu and sigma |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
732 |
*/ |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
733 |
static double GetSingleValue(double mu, double sigma); |
438
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
734 |
private: |
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
735 |
double m_mu; |
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
736 |
double m_sigma; |
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
737 |
}; |
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
738 |
|
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
739 |
|
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
740 |
}//namespace ns3 |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
741 |
#endif |