A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
random-variable.h
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 
40 namespace ns3 {
41 
42 class RandomVariableBase;
43 
59 {
60 public:
61  RandomVariable ();
63  RandomVariable &operator = (const RandomVariable &o);
64  ~RandomVariable ();
65 
70  double GetValue (void) const;
71 
76  uint32_t GetInteger (void) const;
77 
78 private:
79  friend std::ostream & operator << (std::ostream &os, const RandomVariable &var);
80  friend std::istream & operator >> (std::istream &os, RandomVariable &var);
81 
82  RandomVariableBase *m_variable;
83 protected:
84  RandomVariable (const RandomVariableBase &variable);
85  RandomVariableBase * Peek (void) const;
86 };
87 
104 {
105 public:
110  UniformVariable ();
111 
117  UniformVariable (double s, double l);
118 
128  double GetValue (void) const;
129 
136  double GetValue (double s, double l);
137 
144  uint32_t GetInteger (uint32_t s, uint32_t l);
145 };
146 
155 {
156 
157 public:
161  ConstantVariable ();
162 
168  ConstantVariable (double c);
169 
174  void SetConstant (double c);
175 
176 };
177 
188 {
189 public:
201  SequentialVariable (double f, double l, double i = 1, uint32_t c = 1);
202 
213  SequentialVariable (double f, double l, const RandomVariable& i, uint32_t c = 1);
214 
215 };
216 
241 {
242 public:
248 
253  explicit ExponentialVariable (double m);
254 
266  ExponentialVariable (double m, double b);
267 
268 };
269 
291 {
292 public:
297  ParetoVariable ();
298 
305  explicit ParetoVariable (double m);
306 
314  ParetoVariable (double m, double s);
315 
328  ParetoVariable (double m, double s, double b);
329 
336  ParetoVariable (std::pair<double, double> params);
337 
350  ParetoVariable (std::pair<double, double> params, double b);
351 
352 };
353 
369 {
370 public:
375  WeibullVariable ();
376 
377 
383  WeibullVariable (double m);
384 
391  WeibullVariable (double m, double s);
392 
404  WeibullVariable (double m, double s, double b);
405 
406 };
407 
423 {
424 public:
429  NormalVariable ();
430 
436  NormalVariable (double m, double v);
437 
445  NormalVariable (double m, double v, double b);
446 };
447 
464 {
465 public:
469  explicit EmpiricalVariable ();
470 
476  void CDF (double v, double c); // Value, prob <= Value
477 protected:
478  EmpiricalVariable (const RandomVariableBase &variable);
479 };
480 
491 {
492 public:
494 };
495 
506 {
507 public:
519  explicit DeterministicVariable (double* d, uint32_t c);
520 };
521 
545 {
546 public:
551  LogNormalVariable (double mu, double sigma);
552 };
553 
570 {
571 public:
575  GammaVariable ();
576 
581  GammaVariable (double alpha, double beta);
582 
592  double GetValue (void) const;
593 
600  double GetValue (double alpha, double beta) const;
601 };
602 
623 {
624 public:
628  ErlangVariable ();
629 
634  ErlangVariable (unsigned int k, double lambda);
635 
645  double GetValue (void) const;
646 
653  double GetValue (unsigned int k, double lambda) const;
654 };
655 
672 {
673 public:
679  ZipfVariable (long N, double alpha);
683  ZipfVariable ();
684 };
685 
699 {
700 public:
705  ZetaVariable (double alpha);
709  ZetaVariable ();
710 };
711 
720 {
721 public:
727 
735  TriangularVariable (double s, double l, double mean);
736 
737 };
738 
739 std::ostream & operator << (std::ostream &os, const RandomVariable &var);
740 std::istream & operator >> (std::istream &os, RandomVariable &var);
741 
750 
751 } // namespace ns3
752 
753 #endif /* NS3_RANDOM_VARIABLE_H */
std::istream & operator>>(std::istream &is, Angles &a)
Definition: angles.cc:49
A random variable that returns a constantClass ConstantVariable defines a random number generator tha...
Triangularly Distributed random varThis distribution is a triangular distribution. The probability density is in the shape of a triangle.
Erlang Distributed Random VariableErlangVariable defines a random variable with Erlang distribution...
Zipf Distributed Random VariableZipfVariable defines a discrete random variable with Zipf distributio...
ParetoVariable distributed random varThis class supports the creation of objects that return random n...
Class NormalVariable defines a random variable with a normal (Gaussian) distribution.This class supports the creation of objects that return random numbers from a fixed normal distribution. It also supports the generation of single random numbers from various normal distributions.
DeterministicVariable(double *d, uint32_t c)
Constructor.
double GetValue(void) const
call RandomVariable::GetValue
Log-normal Distributed random varLogNormalVariable defines a random variable with log-normal distribu...
double GetValue(void) const
call RandomVariable::GetValue
The uniform distribution RNG for NS-3.This class supports the creation of objects that return random ...
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)
Definition: angles.cc:43
LogNormalVariable(double mu, double sigma)
Zeta Distributed Distributed Random VariableZetaVariable defines a discrete random variable with Zeta...
#define ATTRIBUTE_CHECKER_DEFINE(type)
Exponentially Distributed random varThis class supports the creation of objects that return random nu...
#define ATTRIBUTE_VALUE_DEFINE(type)
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.
#define ATTRIBUTE_ACCESSOR_DEFINE(type)
EmpiricalVariable distribution random varDefines a random variable that has a specified, empirical distribution. The distribution is specified by a series of calls to the CDF member function, specifying a value and the probability that the function value is less than the specified value. When values are requested, a uniform random variable is used to select a probability, and the return value is interpreted linearly between the two appropriate points in the CDF. The method is known as inverse transform sampling: (http://en.wikipedia.org/wiki/Inverse_transform_sampling).
The basic RNG for NS-3.Note: The underlying random number generation method used by NS-3 is the RngSt...
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 ...
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...