A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
random-variable.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 //
3 // Copyright (c) 2006 Georgia Tech Research Corporation
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License version 2 as
7 // published by the Free Software Foundation;
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 //
18 // Author: Rajib Bhattacharjea<raj.b@gatech.edu>
19 // Author: Hadi Arbabi<marbabi@cs.odu.edu>
20 //
21 
22 #ifndef NS3_RANDOM_VARIABLE_H
23 #define NS3_RANDOM_VARIABLE_H
24 
25 #include <vector>
26 #include <algorithm>
27 #include <stdint.h>
28 #include <istream>
29 #include <ostream>
30 #include "attribute.h"
31 #include "attribute-helper.h"
32 #include "rng-seed-manager.h"
33 
39 namespace ns3 {
40 
44 class RandomVariableBase;
45 
61 {
62 public:
63  RandomVariable ();
66  ~RandomVariable ();
67 
72  double GetValue (void) const;
73 
78  uint32_t GetInteger (void) const;
79 
80 private:
81  friend std::ostream & operator << (std::ostream &os, const RandomVariable &var);
82  friend std::istream & operator >> (std::istream &os, RandomVariable &var);
83 
85 protected:
86  RandomVariable (const RandomVariableBase &variable);
87  RandomVariableBase * Peek (void) const;
88 };
89 
106 {
107 public:
112  UniformVariable ();
113 
119  UniformVariable (double s, double l);
120 
130  double GetValue (void) const;
131 
138  double GetValue (double s, double l);
139 
146  uint32_t GetInteger (uint32_t s, uint32_t l);
147 };
148 
157 {
158 
159 public:
163  ConstantVariable ();
164 
170  ConstantVariable (double c);
171 
176  void SetConstant (double c);
177 
178 };
179 
190 {
191 public:
203  SequentialVariable (double f, double l, double i = 1, uint32_t c = 1);
204 
215  SequentialVariable (double f, double l, const RandomVariable& i, uint32_t c = 1);
216 
217 };
218 
243 {
244 public:
250 
255  explicit ExponentialVariable (double m);
256 
268  ExponentialVariable (double m, double b);
269 
270 };
271 
293 {
294 public:
299  ParetoVariable ();
300 
307  explicit ParetoVariable (double m);
308 
316  ParetoVariable (double m, double s);
317 
330  ParetoVariable (double m, double s, double b);
331 
338  ParetoVariable (std::pair<double, double> params);
339 
352  ParetoVariable (std::pair<double, double> params, double b);
353 
354 };
355 
371 {
372 public:
377  WeibullVariable ();
378 
379 
385  WeibullVariable (double m);
386 
393  WeibullVariable (double m, double s);
394 
406  WeibullVariable (double m, double s, double b);
407 
408 };
409 
425 {
426 public:
431  NormalVariable ();
432 
438  NormalVariable (double m, double v);
439 
447  NormalVariable (double m, double v, double b);
448 };
449 
466 {
467 public:
471  explicit EmpiricalVariable ();
472 
478  void CDF (double v, double c); // Value, prob <= Value
479 protected:
480  EmpiricalVariable (const RandomVariableBase &variable);
481 };
482 
493 {
494 public:
496 };
497 
508 {
509 public:
521  explicit DeterministicVariable (double* d, uint32_t c);
522 };
523 
547 {
548 public:
553  LogNormalVariable (double mu, double sigma);
554 };
555 
572 {
573 public:
577  GammaVariable ();
578 
583  GammaVariable (double alpha, double beta);
584 
594  double GetValue (void) const;
595 
602  double GetValue (double alpha, double beta) const;
603 };
604 
625 {
626 public:
630  ErlangVariable ();
631 
636  ErlangVariable (unsigned int k, double lambda);
637 
647  double GetValue (void) const;
648 
655  double GetValue (unsigned int k, double lambda) const;
656 };
657 
674 {
675 public:
681  ZipfVariable (long N, double alpha);
685  ZipfVariable ();
686 };
687 
701 {
702 public:
707  ZetaVariable (double alpha);
711  ZetaVariable ();
712 };
713 
722 {
723 public:
729 
737  TriangularVariable (double s, double l, double mean);
738 
739 };
740 
741 std::ostream & operator << (std::ostream &os, const RandomVariable &var);
742 std::istream & operator >> (std::istream &os, RandomVariable &var);
743 
752 
753 } // namespace ns3
754 
755 #endif /* NS3_RANDOM_VARIABLE_H */
RandomVariableBase * Peek(void) const
std::istream & operator>>(std::istream &is, Angles &a)
initialize a struct Angles from input
Definition: angles.cc:49
TriangularVariable()
Creates a triangle distribution random number generator in the range [0.0 .
ErlangVariable()
Constructs an Erlang random variable with k = 1 and lambda = 1.0.
A random variable that returns a constantClass ConstantVariable defines a random number generator tha...
Triangularly Distributed random varThis distribution is a triangular distribution.
Erlang Distributed Random VariableErlangVariable defines a random variable with Erlang distribution...
Zipf Distributed Random VariableZipfVariable defines a discrete random variable with Zipf distributio...
GammaVariable()
Constructs a gamma random variable with alpha = 1.0 and beta = 1.0.
#define ATTRIBUTE_VALUE_DEFINE(Name)
Declare the attribute value class NameValue for the class Name
ParetoVariable distributed random varThis class supports the creation of objects that return random n...
ExponentialVariable()
Constructs an exponential random variable with a mean value of 1.0.
ZipfVariable()
Constructs a Zipf random variable with N=1 and alpha=0.
NormalVariable()
Constructs an normal random variable with a mean value of 0 and variance of 1.
Class NormalVariable defines a random variable with a normal (Gaussian) distribution.
RandomVariable & operator=(const RandomVariable &o)
Ptr< SampleEmitter > s
DeterministicVariable(double *d, uint32_t c)
Constructor.
WeibullVariable()
Constructs a weibull random variable with a mean value of 1.0 and a shape (alpha) parameter of 1...
friend std::istream & operator>>(std::istream &os, RandomVariable &var)
double GetValue(void) const
call RandomVariable::GetValue
Log-normal Distributed random varLogNormalVariable defines a random variable with log-normal distribu...
ATTRIBUTE_ACCESSOR_DEFINE(Boolean)
double GetValue(void) const
call RandomVariable::GetValue
The uniform distribution RNG for NS-3.
SequentialVariable(double f, double l, double i=1, uint32_t c=1)
Constructor for the SequentialVariable RNG.
Gamma Distributed Random VariableGammaVariable defines a random variable with gamma distribution...
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Definition: angles.cc:43
LogNormalVariable(double mu, double sigma)
RandomVariableBase * m_variable
Zeta Distributed Distributed Random VariableZetaVariable defines a discrete random variable with Zeta...
Exponentially Distributed random varThis class supports the creation of objects that return random nu...
double GetValue(void) const
call RandomVariable::GetValue
Integer-based empirical distributionDefines an empirical distribution where all values are integers...
a non-random variableDefines a random variable that has a specified, predetermined sequence...
void CDF(double v, double c)
Specifies a point in the empirical distribution.
EmpiricalVariable()
Constructor for the EmpiricalVariable random variables.
UniformVariable()
Creates a uniform random number generator in the range [0.0 .
ZetaVariable()
Constructs a Zeta random variable with alpha=3.14.
friend std::ostream & operator<<(std::ostream &os, const RandomVariable &var)
EmpiricalVariable distribution random varDefines a random variable that has a specified, empirical distribution.
The basic RNG for NS-3.
ConstantVariable()
Construct a ConstantVariable RNG that returns zero every sample.
double GetValue(void) const
Returns a random double from the underlying distribution.
uint32_t GetInteger(void) const
Returns a random integer integer from the underlying distribution.
WeibullVariable distributed random varThis class supports the creation of objects that return random ...
ATTRIBUTE_CHECKER_DEFINE(Boolean)
void SetConstant(double c)
Specify a new constant RNG for this generator.
ParetoVariable()
Constructs a pareto random variable with a mean of 1 and a shape parameter of 1.5.
Return a sequential list of valuesClass SequentialVariable defines a random number generator that ret...