author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Thu, 17 Apr 2008 15:30:18 -0700 | |
changeset 2969 | 9d05d2a95dfa |
parent 2965 | 4b28e9740e3b |
child 3267 | d0c70dbe918e |
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> |
676
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
26 |
#include <stdint.h> |
2409
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2408
diff
changeset
|
27 |
#include <istream> |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2408
diff
changeset
|
28 |
#include <ostream> |
2438
e2ac9f9aeeb9
value.h -> attribute.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2437
diff
changeset
|
29 |
#include "attribute.h" |
2451
8979f07befd5
value-helper.h -> attribute-helper.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2445
diff
changeset
|
30 |
#include "attribute-helper.h" |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
31 |
|
396
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
32 |
/** |
2217 | 33 |
* \ingroup core |
396
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
34 |
* \defgroup randomvariable Random Variable Distributions |
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
35 |
* |
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
36 |
*/ |
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
37 |
|
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
38 |
namespace ns3{ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
39 |
|
2336
28ce210b91bb
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2217
diff
changeset
|
40 |
class RandomVariableBase; |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
41 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
42 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
43 |
* \brief The basic RNG for NS-3. |
396
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
44 |
* \ingroup randomvariable |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
45 |
* |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
46 |
* Note: The underlying random number generation method used |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
47 |
* 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
|
48 |
* the University of Montreal. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
49 |
* |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
50 |
* NS-3 has a rich set of random number generators. |
2762
f56860663c54
Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2451
diff
changeset
|
51 |
* Class RandomVariable defines the base class functionalty |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
52 |
* 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
|
53 |
* 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
|
54 |
* 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
|
55 |
* 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
|
56 |
*/ |
2336
28ce210b91bb
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2217
diff
changeset
|
57 |
class RandomVariable |
28ce210b91bb
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2217
diff
changeset
|
58 |
{ |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
59 |
public: |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
60 |
RandomVariable(); |
2336
28ce210b91bb
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2217
diff
changeset
|
61 |
RandomVariable(const RandomVariable&o); |
28ce210b91bb
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2217
diff
changeset
|
62 |
RandomVariable &operator = (const RandomVariable &o); |
28ce210b91bb
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2217
diff
changeset
|
63 |
~RandomVariable(); |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
64 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
65 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
66 |
* \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
|
67 |
* \return A floating point random value |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
68 |
*/ |
2336
28ce210b91bb
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2217
diff
changeset
|
69 |
double GetValue (void) const; |
346
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 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
72 |
* \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
|
73 |
* \return Integer cast of ::GetValue() |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
74 |
*/ |
2439
4a0b22a3f5fa
UintValue -> Uinteger, IntValue -> Integer
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2438
diff
changeset
|
75 |
uint32_t GetInteger (void) const; |
364
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
76 |
|
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
77 |
/** |
364
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
78 |
* \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
|
79 |
* |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
80 |
* 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
|
81 |
* 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
|
82 |
* 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
|
83 |
* \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
|
84 |
* of the RNG. |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
85 |
*/ |
2336
28ce210b91bb
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2217
diff
changeset
|
86 |
void GetSeed(uint32_t seed[6]) const; |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
87 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
88 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
89 |
* \brief Set seeding behavior |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
90 |
* |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
91 |
* 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
|
92 |
* 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
|
93 |
* 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
|
94 |
* 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
|
95 |
* it must be called before the creation of the first instance of a |
2762
f56860663c54
Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2451
diff
changeset
|
96 |
* RandomVariable or subclass. Example: |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
97 |
* \code |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
98 |
* RandomVariable::UseDevRandom(); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
99 |
* UniformVariable x(2,3); //these are seeded randomly |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
100 |
* ExponentialVariable y(120); //etc |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
101 |
* \endcode |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
102 |
* \param udr True if /dev/random desired. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
103 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
104 |
static void UseDevRandom(bool udr = true); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
105 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
106 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
107 |
* \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
|
108 |
* |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
109 |
* 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
|
110 |
* 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
|
111 |
* 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
|
112 |
* random number generator with the specified seed. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
113 |
* 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
|
114 |
* 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
|
115 |
* 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
|
116 |
* 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
|
117 |
* \code |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
118 |
* RandomVariable::UseGlobalSeed(...); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
119 |
* 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
|
120 |
* 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
|
121 |
* \endcode |
423
76a580dfb0f7
Removed the unnecessary Seed classes
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
420
diff
changeset
|
122 |
* \param s0 |
76a580dfb0f7
Removed the unnecessary Seed classes
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
420
diff
changeset
|
123 |
* \param s1 |
76a580dfb0f7
Removed the unnecessary Seed classes
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
420
diff
changeset
|
124 |
* \param s2 |
76a580dfb0f7
Removed the unnecessary Seed classes
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
420
diff
changeset
|
125 |
* \param s3 |
76a580dfb0f7
Removed the unnecessary Seed classes
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
420
diff
changeset
|
126 |
* \param s4 |
76a580dfb0f7
Removed the unnecessary Seed classes
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
420
diff
changeset
|
127 |
* \param s5 |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
128 |
* \return True if seed is valid. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
129 |
*/ |
423
76a580dfb0f7
Removed the unnecessary Seed classes
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
420
diff
changeset
|
130 |
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
|
131 |
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
|
132 |
|
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
133 |
/** |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
134 |
* \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
|
135 |
* |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
136 |
* 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
|
137 |
* 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
|
138 |
* 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
|
139 |
* 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
|
140 |
* 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
|
141 |
* 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
|
142 |
* 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
|
143 |
* 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
|
144 |
* 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
|
145 |
* RandomVariables. For example: |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
146 |
* \code |
423
76a580dfb0f7
Removed the unnecessary Seed classes
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
420
diff
changeset
|
147 |
* 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
|
148 |
* 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
|
149 |
* RandomVariable::SetRunNumber(N); |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
150 |
* UniformVariable x(0,10); |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
151 |
* ExponentialVariable y(2902); |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
152 |
* \endcode |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
153 |
* 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
|
154 |
* 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
|
155 |
* 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
|
156 |
* \code |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
157 |
* ./simulation 0 |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
158 |
* ...Results for run 0:... |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
159 |
* |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
160 |
* ./simulation 1 |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
161 |
* ...Results for run 1:... |
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 |
*/ |
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
164 |
static void SetRunNumber(uint32_t n); |
2384
500ada6a4874
add Value support to RandomVariable.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
165 |
|
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
166 |
private: |
2409
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2408
diff
changeset
|
167 |
friend std::ostream &operator << (std::ostream &os, const RandomVariable &var); |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2408
diff
changeset
|
168 |
friend std::istream &operator >> (std::istream &os, RandomVariable &var); |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2408
diff
changeset
|
169 |
|
2336
28ce210b91bb
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2217
diff
changeset
|
170 |
RandomVariableBase *m_variable; |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
171 |
protected: |
2336
28ce210b91bb
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2217
diff
changeset
|
172 |
RandomVariable (const RandomVariableBase &variable); |
2384
500ada6a4874
add Value support to RandomVariable.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
173 |
RandomVariableBase *Peek (void) const; |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
174 |
}; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
175 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
176 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
177 |
* \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
|
178 |
* \ingroup randomvariable |
1872
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
179 |
* |
442
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
180 |
* 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
|
181 |
* 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
|
182 |
* single random numbers from various uniform distributions. |
1872
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
183 |
* |
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
184 |
* The low end of the range is always included and the high end |
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
185 |
* of the range is always excluded. |
442
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
186 |
* \code |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
187 |
* UniformVariable x(0,10); |
1872
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
188 |
* x.GetValue(); //will always return numbers [0,10) |
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
189 |
* UniformVariable::GetSingleValue(100,1000); //returns a value [100,1000) |
592
f7e4beac3e31
fix dox warnings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
442
diff
changeset
|
190 |
* \endcode |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
191 |
*/ |
2336
28ce210b91bb
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2217
diff
changeset
|
192 |
class UniformVariable : public RandomVariable |
28ce210b91bb
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2217
diff
changeset
|
193 |
{ |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
194 |
public: |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
195 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
196 |
* Creates a uniform random number generator in the |
1872
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
197 |
* range [0.0 .. 1.0). |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
198 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
199 |
UniformVariable(); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
200 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
201 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
202 |
* 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
|
203 |
* \param s Low end of the range |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
204 |
* \param l High end of the range |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
205 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
206 |
UniformVariable(double s, double l); |
442
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
207 |
public: |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
208 |
/** |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
209 |
* \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
|
210 |
* \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
|
211 |
* \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
|
212 |
*/ |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
213 |
static double GetSingleValue(double s, double l); |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
214 |
}; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
215 |
|
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 |
* \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
|
218 |
* \ingroup randomvariable |
360
7bffd987426c
Fixed major memory bug and docs in RandomVariable
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
346
diff
changeset
|
219 |
* |
2762
f56860663c54
Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2451
diff
changeset
|
220 |
* Class ConstantVariable defines a random number generator that |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
221 |
* returns the same value every sample. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
222 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
223 |
class ConstantVariable : public RandomVariable { |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
224 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
225 |
public: |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
226 |
/** |
2762
f56860663c54
Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2451
diff
changeset
|
227 |
* 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
|
228 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
229 |
ConstantVariable(); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
230 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
231 |
/** |
2762
f56860663c54
Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2451
diff
changeset
|
232 |
* Construct a ConstantVariable RNG that returns the specified value |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
233 |
* every sample. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
234 |
* \param c Unchanging value for this RNG. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
235 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
236 |
ConstantVariable(double c); |
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 Specify a new constant RNG for this generator. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
240 |
* \param c New constant value for this RNG. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
241 |
*/ |
2336
28ce210b91bb
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2217
diff
changeset
|
242 |
void SetConstant(double c); |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
243 |
|
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 |
|
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 |
* \brief Return a sequential list of values |
396
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
248 |
* \ingroup randomvariable |
360
7bffd987426c
Fixed major memory bug and docs in RandomVariable
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
346
diff
changeset
|
249 |
* |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
250 |
* Class SequentialVariable defines a random number generator that |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
251 |
* returns a sequential sequence. The sequence monotonically |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
252 |
* 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
|
253 |
* and begins monotonicaly increasing again. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
254 |
*/ |
2336
28ce210b91bb
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2217
diff
changeset
|
255 |
class SequentialVariable : public RandomVariable |
28ce210b91bb
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2217
diff
changeset
|
256 |
{ |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
257 |
public: |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
258 |
/** |
2762
f56860663c54
Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2451
diff
changeset
|
259 |
* \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
|
260 |
* |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
261 |
* The four parameters define the sequence. For example |
2762
f56860663c54
Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2451
diff
changeset
|
262 |
* SequentialVariable(0,5,1,2) creates a RNG that has the sequence |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
263 |
* 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
|
264 |
* \param f First value of the sequence. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
265 |
* \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
|
266 |
* \param i Increment between sequence values |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
267 |
* \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
|
268 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
269 |
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
|
270 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
271 |
/** |
2762
f56860663c54
Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2451
diff
changeset
|
272 |
* \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
|
273 |
* |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
274 |
* 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
|
275 |
* random variable |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
276 |
* \param f First value of the sequence. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
277 |
* \param l One more than the last value of the sequence. |
2762
f56860663c54
Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2451
diff
changeset
|
278 |
* \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
|
279 |
* \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
|
280 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
281 |
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
|
282 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
283 |
}; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
284 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
285 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
286 |
* \brief Exponentially Distributed random var |
396
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
287 |
* \ingroup randomvariable |
1872
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
288 |
* |
442
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
289 |
* 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
|
290 |
* 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
|
291 |
* single random numbers from various exponential distributions. |
1872
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
292 |
* |
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
293 |
* The probability density function of an exponential variable |
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
294 |
* is defined over the interval [0, +inf) as: |
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
295 |
* \f$ \alpha e^{-\alpha x} \f$ |
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
296 |
* where \f$ \alpha = \frac{1}{mean} \f$ |
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
297 |
* |
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
298 |
* The bounded version is defined over the internal [0,+inf) as: |
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
299 |
* \f$ \left\{ \begin{array}{cl} \alpha e^{-\alpha x} & x < bound \\ bound & x > bound \end{array}\right. \f$ |
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
300 |
* |
442
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
301 |
* \code |
2762
f56860663c54
Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2451
diff
changeset
|
302 |
* ExponentialVariable x(3.14); |
442
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
303 |
* x.GetValue(); //will always return with mean 3.14 |
2762
f56860663c54
Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2451
diff
changeset
|
304 |
* ExponentialVariable::GetSingleValue(20.1); //returns with mean 20.1 |
f56860663c54
Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2451
diff
changeset
|
305 |
* ExponentialVariable::GetSingleValue(108); //returns with mean 108 |
442
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
306 |
* \endcode |
360
7bffd987426c
Fixed major memory bug and docs in RandomVariable
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
346
diff
changeset
|
307 |
* |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
308 |
*/ |
2336
28ce210b91bb
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2217
diff
changeset
|
309 |
class ExponentialVariable : public RandomVariable |
28ce210b91bb
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2217
diff
changeset
|
310 |
{ |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
311 |
public: |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
312 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
313 |
* Constructs an exponential random variable with a mean |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
314 |
* value of 1.0. |
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 |
ExponentialVariable(); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
317 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
318 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
319 |
* \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
|
320 |
* \param m Mean value for the random variable |
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 |
explicit ExponentialVariable(double m); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
323 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
324 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
325 |
* \brief Constructs an exponential random variable with spefified |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
326 |
* \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
|
327 |
* |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
328 |
* Since exponential distributions can theoretically return unbounded values, |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
329 |
* 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
|
330 |
* 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
|
331 |
* slightly smaller than the mean value specified. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
332 |
* \param m Mean value of the random variable |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
333 |
* \param b Upper bound on returned values |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
334 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
335 |
ExponentialVariable(double m, double b); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
336 |
|
442
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
337 |
/** |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
338 |
* \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
|
339 |
* \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
|
340 |
* \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
|
341 |
*/ |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
342 |
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
|
343 |
}; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
344 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
345 |
/** |
2762
f56860663c54
Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2451
diff
changeset
|
346 |
* \brief ParetoVariable distributed random var |
396
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
347 |
* \ingroup randomvariable |
1872
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
348 |
* |
442
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
349 |
* 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
|
350 |
* 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
|
351 |
* single random numbers from various pareto distributions. |
1872
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
352 |
* |
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
353 |
* The probability density function is defined over the range [\f$x_m\f$,+inf) as: |
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
354 |
* \f$ k \frac{x_m^k}{x^{k+1}}\f$ where \f$x_m > 0\f$ is called the location |
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
355 |
* parameter and \f$ k > 0\f$ is called the pareto index or shape. |
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
356 |
* |
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
357 |
* The parameter \f$ x_m \f$ can be infered from the mean and the parameter \f$ k \f$ |
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
358 |
* with the equation \f$ x_m = mean \frac{k-1}{k}, k > 1\f$. |
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
359 |
* |
442
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
360 |
* \code |
2762
f56860663c54
Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2451
diff
changeset
|
361 |
* ParetoVariable x(3.14); |
442
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
362 |
* x.GetValue(); //will always return with mean 3.14 |
2762
f56860663c54
Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2451
diff
changeset
|
363 |
* ParetoVariable::GetSingleValue(20.1); //returns with mean 20.1 |
f56860663c54
Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2451
diff
changeset
|
364 |
* ParetoVariable::GetSingleValue(108); //returns with mean 108 |
442
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
365 |
* \endcode |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
366 |
*/ |
2336
28ce210b91bb
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2217
diff
changeset
|
367 |
class ParetoVariable : public RandomVariable |
28ce210b91bb
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2217
diff
changeset
|
368 |
{ |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
369 |
public: |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
370 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
371 |
* 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
|
372 |
* parameter of 1.5 |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
373 |
*/ |
2336
28ce210b91bb
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2217
diff
changeset
|
374 |
ParetoVariable (); |
346
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 |
* 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
|
378 |
* parameter of 1.5 |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
379 |
* \param m Mean value of the distribution |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
380 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
381 |
explicit ParetoVariable(double m); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
382 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
383 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
384 |
* 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
|
385 |
* shape parameter. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
386 |
* \param m Mean value of the distribution |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
387 |
* \param s Shape parameter for the distribution |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
388 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
389 |
ParetoVariable(double m, double s); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
390 |
|
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 |
* \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
|
393 |
* \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
|
394 |
* |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
395 |
* Since pareto distributions can theoretically return unbounded values, |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
396 |
* 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
|
397 |
* 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
|
398 |
* is slightly smaller than the mean value specified. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
399 |
* \param m Mean value |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
400 |
* \param s Shape parameter |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
401 |
* \param b Upper limit on returned values |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
402 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
403 |
ParetoVariable(double m, double s, double b); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
404 |
|
442
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
405 |
/** |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
406 |
* \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
|
407 |
* is drawn. |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
408 |
* \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
|
409 |
* value is drawn. |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
410 |
* \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
|
411 |
* \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
|
412 |
* parameter s. |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
413 |
*/ |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
414 |
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
|
415 |
}; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
416 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
417 |
/** |
2762
f56860663c54
Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2451
diff
changeset
|
418 |
* \brief WeibullVariable distributed random var |
396
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
419 |
* \ingroup randomvariable |
1872
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
420 |
* |
442
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
421 |
* 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
|
422 |
* 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
|
423 |
* single random numbers from various weibull distributions. |
1872
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
424 |
* |
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
425 |
* The probability density function is defined over the interval [0, +inf] |
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
426 |
* as: \f$ \frac{k}{\lambda}\left(\frac{x}{\lambda}\right)^{k-1}e^{-\left(\frac{x}{\lambda}\right)^k} \f$ |
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
427 |
* where \f$ k > 0\f$ is the shape parameter and \f$ \lambda > 0\f$ is the scale parameter. The |
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
428 |
* specified mean is related to the scale and shape parameters by the following relation: |
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
429 |
* \f$ mean = \lambda\Gamma\left(1+\frac{1}{k}\right) \f$ where \f$ \Gamma \f$ is the Gamma function. |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
430 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
431 |
class WeibullVariable : public RandomVariable { |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
432 |
public: |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
433 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
434 |
* Constructs a weibull random variable with a mean |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
435 |
* 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
|
436 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
437 |
WeibullVariable(); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
438 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
439 |
|
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 |
* 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
|
442 |
* 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
|
443 |
* \param m mean value of the distribution |
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 |
WeibullVariable(double m) ; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
446 |
|
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 |
* 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
|
449 |
* value and a shape (alpha). |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
450 |
* \param m Mean value for the distribution. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
451 |
* \param s Shape (alpha) parameter for the distribution. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
452 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
453 |
WeibullVariable(double m, double s); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
454 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
455 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
456 |
* \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
|
457 |
* \brief value, shape (alpha), and upper bound. |
2762
f56860663c54
Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2451
diff
changeset
|
458 |
* Since WeibullVariable distributions can theoretically return unbounded values, |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
459 |
* 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
|
460 |
* 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
|
461 |
* is slightly smaller than the mean value specified. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
462 |
* \param m Mean value for the distribution. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
463 |
* \param s Shape (alpha) parameter for the distribution. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
464 |
* \param b Upper limit on returned values |
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 |
WeibullVariable(double m, double s, double b); |
442
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
467 |
/** |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
468 |
* \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
|
469 |
* \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
|
470 |
* \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
|
471 |
* \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
|
472 |
*/ |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
473 |
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
|
474 |
}; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
475 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
476 |
/** |
2762
f56860663c54
Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2451
diff
changeset
|
477 |
* \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
|
478 |
* normal (Gaussian) distribution. |
1872
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
479 |
* \ingroup randomvariable |
442
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
480 |
* |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
481 |
* 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
|
482 |
* 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
|
483 |
* single random numbers from various normal distributions. |
1872
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
484 |
* |
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
485 |
* The density probability function is defined over the interval (-inf,+inf) |
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
486 |
* as: \f$ \frac{1}{\sigma\sqrt{2\pi}} e^{-\frac{(x-\mu)^2}{s\sigma^2}}\f$ |
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
487 |
* where \f$ mean = \mu \f$ and \f$ variance = \sigma^2 \f$ |
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
488 |
* |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
489 |
*/ |
2336
28ce210b91bb
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2217
diff
changeset
|
490 |
class NormalVariable : public RandomVariable |
28ce210b91bb
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2217
diff
changeset
|
491 |
{ |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
492 |
public: |
420
32ebc6582692
Fixed NormalVariable::INFINITE_VALUE
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
397
diff
changeset
|
493 |
static const double INFINITE_VALUE; |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
494 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
495 |
* Constructs an normal random variable with a mean |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
496 |
* value of 0 and variance of 1. |
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 |
NormalVariable(); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
499 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
500 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
501 |
* \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
|
502 |
* \param m Mean value |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
503 |
* \param v Variance |
2762
f56860663c54
Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2451
diff
changeset
|
504 |
* \param b Bound. The NormalVariable is bounded within +-bound. |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
505 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
506 |
NormalVariable(double m, double v, double b = INFINITE_VALUE); |
442
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
507 |
/** |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
508 |
* \param m Mean value |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
509 |
* \param v Variance |
2762
f56860663c54
Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2451
diff
changeset
|
510 |
* \param b Bound. The NormalVariable is bounded within +-bound. |
442
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
511 |
* \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
|
512 |
*/ |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
513 |
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
|
514 |
}; |
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 |
/** |
2762
f56860663c54
Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2451
diff
changeset
|
517 |
* \brief EmpiricalVariable distribution random var |
396
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
518 |
* \ingroup randomvariable |
360
7bffd987426c
Fixed major memory bug and docs in RandomVariable
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
346
diff
changeset
|
519 |
* |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
520 |
* 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
|
521 |
* distribution. The distribution is specified by a |
1872
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
522 |
* series of calls to the CDF member function, specifying a |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
523 |
* 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
|
524 |
* the specified value. When values are requested, |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
525 |
* 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
|
526 |
* and the return value is interpreted linerarly between the |
2762
f56860663c54
Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2451
diff
changeset
|
527 |
* two appropriate points in the CDF. The method is known |
f56860663c54
Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2451
diff
changeset
|
528 |
* as inverse transform sampling: |
f56860663c54
Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2451
diff
changeset
|
529 |
* (http://en.wikipedia.org/wiki/Inverse_transform_sampling). |
346
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 |
class EmpiricalVariable : public RandomVariable { |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
532 |
public: |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
533 |
/** |
2762
f56860663c54
Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2451
diff
changeset
|
534 |
* Constructor for the EmpiricalVariable random variables. |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
535 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
536 |
explicit EmpiricalVariable(); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
537 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
538 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
539 |
* \brief Specifies a point in the empirical distribution |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
540 |
* \param v The function value for this point |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
541 |
* \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
|
542 |
*/ |
2336
28ce210b91bb
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2217
diff
changeset
|
543 |
void CDF(double v, double c); // Value, prob <= Value |
28ce210b91bb
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2217
diff
changeset
|
544 |
protected: |
28ce210b91bb
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2217
diff
changeset
|
545 |
EmpiricalVariable (const RandomVariableBase &variable); |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
546 |
}; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
547 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
548 |
/** |
396
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
549 |
* \brief Integer-based empirical distribution |
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
550 |
* \ingroup randomvariable |
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
551 |
* |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
552 |
* Defines an empirical distribution where all values are integers. |
2762
f56860663c54
Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2451
diff
changeset
|
553 |
* Indentical to EmpiricalVariable, except that the inverse transform |
f56860663c54
Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2451
diff
changeset
|
554 |
* sampling interpolation described in the EmpiricalVariable documentation |
f56860663c54
Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2451
diff
changeset
|
555 |
* is modified to only return integers. |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
556 |
*/ |
2336
28ce210b91bb
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2217
diff
changeset
|
557 |
class IntEmpiricalVariable : public EmpiricalVariable |
28ce210b91bb
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2217
diff
changeset
|
558 |
{ |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
559 |
public: |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
560 |
IntEmpiricalVariable(); |
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 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
563 |
/** |
396
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
564 |
* \brief a non-random variable |
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
565 |
* \ingroup randomvariable |
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
566 |
* |
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
567 |
* 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
|
568 |
* 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
|
569 |
* 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
|
570 |
* compare NS-3 to some other simulator |
7b4349cd88bc
add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
364
diff
changeset
|
571 |
*/ |
2336
28ce210b91bb
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2217
diff
changeset
|
572 |
class DeterministicVariable : public RandomVariable |
28ce210b91bb
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2217
diff
changeset
|
573 |
{ |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
574 |
public: |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
575 |
/** |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
576 |
* \brief Constructor |
360
7bffd987426c
Fixed major memory bug and docs in RandomVariable
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
346
diff
changeset
|
577 |
* |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
578 |
* 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
|
579 |
* 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
|
580 |
* 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
|
581 |
* contents of the array d points to have to remain unchanged for the use |
2762
f56860663c54
Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2451
diff
changeset
|
582 |
* of DeterministicVariable to be meaningful. |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
583 |
* \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
|
584 |
* \param c Number of values in the array |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
585 |
*/ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
586 |
explicit DeterministicVariable(double* d, uint32_t c); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
587 |
}; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
588 |
|
438
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
589 |
|
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
590 |
/** |
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
591 |
* \brief Log-normal Distributed random var |
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
592 |
* \ingroup randomvariable |
1872
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
593 |
* |
2762
f56860663c54
Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2451
diff
changeset
|
594 |
* LogNormalVariable defines a random variable with log-normal |
438
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
595 |
* distribution. If one takes the natural logarithm of random |
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
596 |
* variable following the log-normal distribution, the obtained values |
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
597 |
* follow a normal distribution. |
442
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
598 |
* 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
|
599 |
* 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
|
600 |
* single random numbers from various lognormal distributions. |
1872
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
601 |
* |
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
602 |
* The probability density function is defined over the interval [0,+inf) as: |
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
603 |
* \f$ \frac{1}{x\sigma\sqrt{2\pi}} e^{-\frac{(ln(x) - \mu)^2}{2\sigma^2}}\f$ |
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
604 |
* where \f$ mean = e^{\mu+\frac{\sigma^2}{2}} \f$ and |
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
605 |
* \f$ variance = (e^{\sigma^2}-1)e^{2\mu+\sigma^2}\f$ |
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
606 |
* |
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
607 |
* The \f$ \mu \f$ and \f$ \sigma \f$ parameters can be calculated from the mean |
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
608 |
* and standard deviation with the following equations: |
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
609 |
* \f$ \mu = ln(mean) - \frac{1}{2}ln\left(1+\frac{stddev}{mean^2}\right)\f$, and, |
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
610 |
* \f$ \sigma = \sqrt{ln\left(1+\frac{stddev}{mean^2}\right)}\f$ |
438
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
611 |
*/ |
2336
28ce210b91bb
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2217
diff
changeset
|
612 |
class LogNormalVariable : public RandomVariable |
28ce210b91bb
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2217
diff
changeset
|
613 |
{ |
438
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
614 |
public: |
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
615 |
/** |
1872
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
616 |
* \param mu mu parameter of the lognormal distribution |
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
617 |
* \param sigma sigma parameter of the lognormal distribution |
438
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
618 |
*/ |
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
619 |
LogNormalVariable (double mu, double sigma); |
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
620 |
|
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
621 |
/** |
1872
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
622 |
* \param mu mu parameter of the underlying normal distribution |
4dfb2a623722
bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1806
diff
changeset
|
623 |
* \param sigma sigma parameter of the underlying normal distribution |
442
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
624 |
* \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
|
625 |
*/ |
96d3e7dc8bb2
Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
438
diff
changeset
|
626 |
static double GetSingleValue(double mu, double sigma); |
438
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
627 |
}; |
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
628 |
|
942
b65368bf40f9
Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
676
diff
changeset
|
629 |
/** |
b65368bf40f9
Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
676
diff
changeset
|
630 |
* \brief Triangularly Distributed random var |
b65368bf40f9
Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
676
diff
changeset
|
631 |
* \ingroup randomvariable |
b65368bf40f9
Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
676
diff
changeset
|
632 |
* |
b65368bf40f9
Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
676
diff
changeset
|
633 |
* This distribution is a triangular distribution. The probablility density |
b65368bf40f9
Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
676
diff
changeset
|
634 |
* is in the shape of a triangle. |
b65368bf40f9
Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
676
diff
changeset
|
635 |
*/ |
2336
28ce210b91bb
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2217
diff
changeset
|
636 |
class TriangularVariable : public RandomVariable |
28ce210b91bb
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2217
diff
changeset
|
637 |
{ |
942
b65368bf40f9
Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
676
diff
changeset
|
638 |
public: |
b65368bf40f9
Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
676
diff
changeset
|
639 |
/** |
b65368bf40f9
Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
676
diff
changeset
|
640 |
* Creates a triangle distribution random number generator in the |
b65368bf40f9
Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
676
diff
changeset
|
641 |
* range [0.0 .. 1.0), with mean of 0.5 |
b65368bf40f9
Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
676
diff
changeset
|
642 |
*/ |
b65368bf40f9
Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
676
diff
changeset
|
643 |
TriangularVariable(); |
b65368bf40f9
Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
676
diff
changeset
|
644 |
|
b65368bf40f9
Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
676
diff
changeset
|
645 |
/** |
b65368bf40f9
Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
676
diff
changeset
|
646 |
* Creates a triangle distribution random number generator with the specified |
b65368bf40f9
Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
676
diff
changeset
|
647 |
* range |
b65368bf40f9
Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
676
diff
changeset
|
648 |
* \param s Low end of the range |
b65368bf40f9
Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
676
diff
changeset
|
649 |
* \param l High end of the range |
b65368bf40f9
Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
676
diff
changeset
|
650 |
* \param mean mean of the distribution |
b65368bf40f9
Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
676
diff
changeset
|
651 |
*/ |
b65368bf40f9
Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
676
diff
changeset
|
652 |
TriangularVariable(double s, double l, double mean); |
b65368bf40f9
Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
676
diff
changeset
|
653 |
/** |
b65368bf40f9
Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
676
diff
changeset
|
654 |
* \param s Low end of the range |
b65368bf40f9
Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
676
diff
changeset
|
655 |
* \param l High end of the range |
1250
243eb985ad00
fix dox warning
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
942
diff
changeset
|
656 |
* \param mean mean of the distribution |
942
b65368bf40f9
Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
676
diff
changeset
|
657 |
* \return A triangularly distributed random number between s and l |
b65368bf40f9
Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
676
diff
changeset
|
658 |
*/ |
b65368bf40f9
Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
676
diff
changeset
|
659 |
static double GetSingleValue(double s, double l, double mean); |
b65368bf40f9
Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
676
diff
changeset
|
660 |
}; |
438
515bb5663cf3
Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
423
diff
changeset
|
661 |
|
2409
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2408
diff
changeset
|
662 |
std::ostream &operator << (std::ostream &os, const RandomVariable &var); |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2408
diff
changeset
|
663 |
std::istream &operator >> (std::istream &os, RandomVariable &var); |
2384
500ada6a4874
add Value support to RandomVariable.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
664 |
|
2969
9d05d2a95dfa
improve the auto-generated doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2965
diff
changeset
|
665 |
/** |
9d05d2a95dfa
improve the auto-generated doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2965
diff
changeset
|
666 |
* \class ns3::RandomVariableValue |
9d05d2a95dfa
improve the auto-generated doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2965
diff
changeset
|
667 |
* \brief hold objects of type ns3::RandomVariable |
9d05d2a95dfa
improve the auto-generated doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2965
diff
changeset
|
668 |
*/ |
9d05d2a95dfa
improve the auto-generated doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2965
diff
changeset
|
669 |
|
2445
e1b65471f159
convert RandomVariable to new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2439
diff
changeset
|
670 |
ATTRIBUTE_VALUE_DEFINE (RandomVariable); |
e1b65471f159
convert RandomVariable to new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2439
diff
changeset
|
671 |
ATTRIBUTE_CHECKER_DEFINE (RandomVariable); |
e1b65471f159
convert RandomVariable to new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2439
diff
changeset
|
672 |
ATTRIBUTE_ACCESSOR_DEFINE (RandomVariable); |
2384
500ada6a4874
add Value support to RandomVariable.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
673 |
|
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
674 |
}//namespace ns3 |
2384
500ada6a4874
add Value support to RandomVariable.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
675 |
|
500ada6a4874
add Value support to RandomVariable.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
676 |
|
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
677 |
#endif |