src/core/random-variable.h
author Raj Bhattacharjea <raj.b@gatech.edu>
Tue, 20 Jan 2009 16:36:08 -0500
changeset 4223 86a97665dcb0
parent 4218 debf1a8a96d3
child 4224 40e5d5af3c71
permissions -rw-r--r--
Fix old code that crept in
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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>
4218
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    19
// Author: Hadi Arbabi<marbabi@cs.odu.edu>
346
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
4218
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    22
#ifndef __random_variable_h
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    23
#define __random_variable_h
346
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    24
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    25
#include <vector>
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    26
#include <algorithm>
676
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
    27
#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
    28
#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
    29
#include <ostream>
2438
e2ac9f9aeeb9 value.h -> attribute.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2437
diff changeset
    30
#include "attribute.h"
2451
8979f07befd5 value-helper.h -> attribute-helper.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2445
diff changeset
    31
#include "attribute-helper.h"
346
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    32
396
7b4349cd88bc add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 364
diff changeset
    33
/**
2217
0b4567d545de Doxygen organization
Tom Henderson <tomh@tomh.org>
parents: 1872
diff changeset
    34
 * \ingroup core
396
7b4349cd88bc add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 364
diff changeset
    35
 * \defgroup randomvariable Random Variable Distributions
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
 */
7b4349cd88bc add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 364
diff changeset
    38
346
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    39
namespace ns3{
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    40
2336
28ce210b91bb bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2217
diff changeset
    41
class RandomVariableBase;
346
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    42
4218
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    43
class SeedManager
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    44
{
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    45
private:
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    46
 static uint32_t runNumber;
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    47
 static bool seedSet;
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    48
 static uint32_t seed_[6];
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    49
 
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    50
public:
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    51
	  
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    52
	 /**
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    53
	 * \brief set the seed
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    54
	 * it will duplicate the seed value 6 times
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    55
	 * \code
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    56
	 * SeedManger::SetSeed(15);
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    57
	 * UniformVariable x(2,3);     //these will give the same output everytime
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    58
	 * ExponentialVariable y(120); //as long as the seed stays the same
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    59
	 * \endcode
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    60
	 * \param seed
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    61
	 */ 
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    62
	static void SetSeed (uint32_t seed);
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    63
 
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    64
	 /**
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    65
	  * \brief Get the seed value
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    66
	  * \return seed value
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    67
	  */
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    68
 	static uint32_t GetSeed ();
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    69
 
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    70
	 /**
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    71
	 * \brief set the seed
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    72
	 * \code
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    73
	 * uint32_t seed[6]={10,5,2,3,5,11};
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    74
	 * SeedManger::SetSeed(seed);
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    75
	 * UniformVariable x(2,3);     //these will give the same output everytime
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    76
	 * ExponentialVariable y(120); //as long as the seed stays the same
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    77
	 * \endcode
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    78
	 * \param seed
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    79
	 */ 
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    80
 	static void SetSeed (uint32_t seed[6]);
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    81
 
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    82
	/**
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    83
	 * \brief Get the seed value
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    84
	 * \param array of size 6 which will hold returned seed values
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    85
	 */
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    86
 	static void GetSeed (uint32_t seed[6]);
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    87
 
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    88
 	/**
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    89
    * \brief Set the run number of simulation
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    90
    *
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    91
    * \code
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    92
    * SeedManager::SetSeed(12);
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    93
    * int N = atol(argv[1]); //read in run number from command line
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    94
    * SeedManager::SetRun(N);
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    95
    * UniformVariable x(0,10);
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    96
    * ExponentialVariable y(2902);
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    97
    * \endcode
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    98
    * In this example, N could successivly be equal to 1,2,3, etc. and the user
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
    99
    * would continue to get independent runs out of the single simulation.  For
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   100
    * this simple example, the following might work:
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   101
    * \code
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   102
    * ./simulation 0
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   103
    * ...Results for run 0:...
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   104
    *
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   105
    * ./simulation 1
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   106
    * ...Results for run 1:...
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   107
    * \endcode
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   108
    */
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   109
	static void SetRun (uint32_t run);
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   110
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   111
	/**
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   112
	 * \brief Get the run number
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   113
	 * \return run number
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   114
	 */
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   115
	static uint32_t GetRun ();
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   116
	
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   117
	/**
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   118
	 * \brief Check if seed value is valid if wanted to be used as seed
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   119
	 * \return true if valid and false if invalid
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   120
	 */
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   121
	static bool CheckSeed (uint32_t seed);
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   122
	
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   123
    /**
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   124
     * \brief Checks if seed array has valid values if wanted to be used as further seed
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   125
     * \return true if valid and false if invalid
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   126
     */
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   127
	static bool CheckSeed (uint32_t seed[6]);
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   128
};
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   129
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   130
346
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   131
/**
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   132
 * \brief The basic RNG for NS-3.
396
7b4349cd88bc add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 364
diff changeset
   133
 * \ingroup randomvariable
346
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   134
 *
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   135
 * Note: The underlying random number generation method used
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   136
 * 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
   137
 * the University of Montreal.
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   138
 * 
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   139
 * 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
   140
 * Class RandomVariable defines the base class functionalty
346
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   141
 * 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
   142
 * 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
   143
 * 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
   144
 * 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
   145
 */
2336
28ce210b91bb bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2217
diff changeset
   146
class RandomVariable
28ce210b91bb bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2217
diff changeset
   147
{ 
346
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   148
public:
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   149
  RandomVariable();
2336
28ce210b91bb bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2217
diff changeset
   150
  RandomVariable(const RandomVariable&o);
28ce210b91bb bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2217
diff changeset
   151
  RandomVariable &operator = (const RandomVariable &o);
28ce210b91bb bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2217
diff changeset
   152
  ~RandomVariable();
346
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   153
  
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   154
  /**
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   155
   * \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
   156
   * \return A floating point random value
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   157
   */
2336
28ce210b91bb bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2217
diff changeset
   158
  double GetValue (void) const;
346
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   159
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   160
  /**
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   161
   * \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
   162
   * \return  Integer cast of ::GetValue()
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   163
   */
2439
4a0b22a3f5fa UintValue -> Uinteger, IntValue -> Integer
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   164
  uint32_t GetInteger (void) const;
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);
4218
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   207
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   208
  /**
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   209
  * \brief Returns a random double with the specified range given by constructor
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   210
  * \return A floating point random value
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   211
  */
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   212
  double GetValue();
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   213
  
442
96d3e7dc8bb2 Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 438
diff changeset
   214
  /**
4218
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   215
  * \brief Returns a random double with the specified range
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   216
  * \param s Low end of the range
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   217
  * \param l High end of the range
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   218
  * \return A floating point random value
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   219
  */
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   220
  double GetValue(double s, double l);
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   221
346
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
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
 * \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
   226
 * \ingroup randomvariable
360
7bffd987426c Fixed major memory bug and docs in RandomVariable
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 346
diff changeset
   227
 *
2762
f56860663c54 Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 2451
diff changeset
   228
 * 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
   229
 * returns the same value every sample.
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
class ConstantVariable : public RandomVariable { 
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   232
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   233
public:
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   234
  /**
2762
f56860663c54 Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 2451
diff changeset
   235
   * 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
   236
   */
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   237
  ConstantVariable();
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
  /**
2762
f56860663c54 Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 2451
diff changeset
   240
   * 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
   241
   * every sample.
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   242
   * \param c Unchanging value for this RNG.
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
  ConstantVariable(double c);
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 Specify a new constant RNG for this generator.
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   248
   * \param c New constant value for this RNG.
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   249
   */
2336
28ce210b91bb bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2217
diff changeset
   250
  void SetConstant(double c);
346
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   251
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   252
};
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   253
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   254
/**
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   255
 * \brief Return a sequential list of values
396
7b4349cd88bc add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 364
diff changeset
   256
 * \ingroup randomvariable
360
7bffd987426c Fixed major memory bug and docs in RandomVariable
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 346
diff changeset
   257
 *
346
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   258
 * Class SequentialVariable defines a random number generator that
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   259
 * returns a sequential sequence.  The sequence monotonically
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   260
 * 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
   261
 * and begins monotonicaly increasing again.
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   262
 */
2336
28ce210b91bb bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2217
diff changeset
   263
class SequentialVariable : public RandomVariable 
28ce210b91bb bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2217
diff changeset
   264
{
346
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   265
public:
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   266
  /**
2762
f56860663c54 Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 2451
diff changeset
   267
   * \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
   268
   *
346
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   269
   * 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
   270
   * 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
   271
   * 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
   272
   * \param f First value of the sequence.
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   273
   * \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
   274
   * \param i Increment between sequence values
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   275
   * \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
   276
   */
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   277
  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
   278
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   279
  /**
2762
f56860663c54 Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 2451
diff changeset
   280
   * \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
   281
   *
346
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   282
   * 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
   283
   * random variable
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   284
   * \param f First value of the sequence.
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   285
   * \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
   286
   * \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
   287
   * \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
   288
   */
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   289
  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
   290
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   291
};
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   292
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   293
/**
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   294
 * \brief Exponentially Distributed random var
396
7b4349cd88bc add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 364
diff changeset
   295
 * \ingroup randomvariable
1872
4dfb2a623722 bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1806
diff changeset
   296
 *
442
96d3e7dc8bb2 Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 438
diff changeset
   297
 * 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
   298
 * 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
   299
 * 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
   300
 *
4dfb2a623722 bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1806
diff changeset
   301
 * 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
   302
 * 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
   303
 * \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
   304
 * 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
   305
 *
4dfb2a623722 bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1806
diff changeset
   306
 * 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
   307
 * \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
   308
 * 
442
96d3e7dc8bb2 Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 438
diff changeset
   309
 * \code
2762
f56860663c54 Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 2451
diff changeset
   310
 * ExponentialVariable x(3.14);
442
96d3e7dc8bb2 Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 438
diff changeset
   311
 * 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
   312
 * 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
   313
 * 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
   314
 * \endcode
360
7bffd987426c Fixed major memory bug and docs in RandomVariable
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 346
diff changeset
   315
 *
346
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   316
 */
2336
28ce210b91bb bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2217
diff changeset
   317
class ExponentialVariable : public RandomVariable 
28ce210b91bb bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2217
diff changeset
   318
{ 
346
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   319
public:
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   320
  /**
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   321
   * Constructs an exponential random variable  with a mean
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   322
   * value of 1.0.
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
  ExponentialVariable();
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   325
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   326
  /**
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   327
   * \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
   328
   * \param m Mean value for the random variable
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   329
   */
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   330
  explicit ExponentialVariable(double m);
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   331
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   332
  /**
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   333
   * \brief Constructs an exponential random variable with spefified
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   334
   * \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
   335
   *
346
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   336
   * Since exponential distributions can theoretically return unbounded values,
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   337
   * 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
   338
   * 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
   339
   * slightly smaller than the mean value specified.
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   340
   * \param m Mean value of the random variable
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   341
   * \param b Upper bound on returned values
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   342
   */
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   343
  ExponentialVariable(double m, double b);
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
};
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   346
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   347
/**
2762
f56860663c54 Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 2451
diff changeset
   348
 * \brief ParetoVariable distributed random var
396
7b4349cd88bc add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 364
diff changeset
   349
 * \ingroup randomvariable
1872
4dfb2a623722 bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1806
diff changeset
   350
 *
442
96d3e7dc8bb2 Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 438
diff changeset
   351
 * 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
   352
 * 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
   353
 * 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
   354
 *
4dfb2a623722 bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1806
diff changeset
   355
 * 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
   356
 * \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
   357
 * 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
   358
 * 
4dfb2a623722 bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1806
diff changeset
   359
 * 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
   360
 * 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
   361
 *
442
96d3e7dc8bb2 Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 438
diff changeset
   362
 * \code
2762
f56860663c54 Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 2451
diff changeset
   363
 * ParetoVariable x(3.14);
442
96d3e7dc8bb2 Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 438
diff changeset
   364
 * 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
   365
 * 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
   366
 * 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
   367
 * \endcode
346
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   368
 */
2336
28ce210b91bb bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2217
diff changeset
   369
class ParetoVariable : public RandomVariable
28ce210b91bb bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2217
diff changeset
   370
{
346
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   371
public:
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   372
  /**
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   373
   * 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
   374
   * parameter of 1.5
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   375
   */
2336
28ce210b91bb bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2217
diff changeset
   376
  ParetoVariable ();
346
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   377
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   378
  /**
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   379
   * 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
   380
   * parameter of 1.5
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   381
   * \param m Mean value of the distribution
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
  explicit ParetoVariable(double m);
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   384
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   385
  /**
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   386
   * 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
   387
   * shape parameter.
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   388
   * \param m Mean value of the distribution
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   389
   * \param s Shape parameter for the distribution
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
  ParetoVariable(double m, double s);
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   392
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   393
  /**
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   394
   * \brief 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
   395
   * \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
   396
   *
346
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   397
   * Since pareto distributions can theoretically return unbounded values,
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   398
   * 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
   399
   * 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
   400
   * is slightly smaller than the mean value specified.
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   401
   * \param m Mean value
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   402
   * \param s Shape parameter
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   403
   * \param b Upper limit on returned values
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   404
   */
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   405
  ParetoVariable(double m, double s, double b);
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   406
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   407
};
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   408
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   409
/**
2762
f56860663c54 Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 2451
diff changeset
   410
 * \brief WeibullVariable distributed random var
396
7b4349cd88bc add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 364
diff changeset
   411
 * \ingroup randomvariable
1872
4dfb2a623722 bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1806
diff changeset
   412
 *
442
96d3e7dc8bb2 Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 438
diff changeset
   413
 * 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
   414
 * 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
   415
 * 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
   416
 *
4dfb2a623722 bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1806
diff changeset
   417
 * 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
   418
 * 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
   419
 * 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
   420
 * 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
   421
 * \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
   422
 */
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   423
class WeibullVariable : public RandomVariable {
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   424
public:
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   425
  /**
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   426
   * Constructs a weibull random variable  with a mean
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   427
   * 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
   428
   */
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   429
  WeibullVariable();
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
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   432
  /**
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   433
   * 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
   434
   * 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
   435
   * \param m mean value of the distribution
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(double m) ;
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
   * 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
   441
   * value and a shape (alpha).
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   442
   * \param m Mean value for the distribution.
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   443
   * \param s Shape (alpha) parameter for 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, double s);
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
   * \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
   449
   * \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
   450
   * 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
   451
   * 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
   452
   * 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
   453
   * is slightly smaller than the mean value specified.
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   454
   * \param m Mean value for the distribution.
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   455
   * \param s Shape (alpha) parameter for the distribution.
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   456
   * \param b Upper limit on returned values
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   457
   */
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   458
  WeibullVariable(double m, double s, double b);
4218
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   459
346
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   460
};
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   461
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   462
/**
2762
f56860663c54 Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 2451
diff changeset
   463
 * \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
   464
 * normal (Gaussian) distribution.
1872
4dfb2a623722 bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1806
diff changeset
   465
 * \ingroup randomvariable
442
96d3e7dc8bb2 Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 438
diff changeset
   466
 * 
96d3e7dc8bb2 Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 438
diff changeset
   467
 * 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
   468
 * 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
   469
 * 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
   470
 *
4dfb2a623722 bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1806
diff changeset
   471
 * 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
   472
 * 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
   473
 * 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
   474
 *
346
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   475
 */
2336
28ce210b91bb bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2217
diff changeset
   476
class NormalVariable : public RandomVariable
28ce210b91bb bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2217
diff changeset
   477
{
346
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   478
public:
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   479
  /**
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   480
   * Constructs an normal random variable  with a mean
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   481
   * value of 0 and variance of 1.
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   482
   */ 
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   483
  NormalVariable();
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   484
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   485
  /**
4223
86a97665dcb0 Fix old code that crept in
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 4218
diff changeset
   486
   * \brief Construct a normal random variable with specified mean and variance.
86a97665dcb0 Fix old code that crept in
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 4218
diff changeset
   487
   * \param m Mean value
86a97665dcb0 Fix old code that crept in
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 4218
diff changeset
   488
   * \param v Variance
86a97665dcb0 Fix old code that crept in
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 4218
diff changeset
   489
   */ 
86a97665dcb0 Fix old code that crept in
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 4218
diff changeset
   490
  NormalVariable(double m, double v);
86a97665dcb0 Fix old code that crept in
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 4218
diff changeset
   491
86a97665dcb0 Fix old code that crept in
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 4218
diff changeset
   492
  /**
346
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   493
   * \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
   494
   * \param m Mean value
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   495
   * \param v Variance
4223
86a97665dcb0 Fix old code that crept in
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 4218
diff changeset
   496
   * \param b Bound.  The NormalVariable is bounded symetrically about the mean
86a97665dcb0 Fix old code that crept in
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 4218
diff changeset
   497
   * [mean-bound,mean+bound]
3267
d0c70dbe918e bug 181: Normal Variable Infinite Value & Bounds
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 2969
diff changeset
   498
   */ 
4223
86a97665dcb0 Fix old code that crept in
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 4218
diff changeset
   499
  NormalVariable(double m, double v, double b);
346
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
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   502
/**
2762
f56860663c54 Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 2451
diff changeset
   503
 * \brief EmpiricalVariable distribution random var
396
7b4349cd88bc add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 364
diff changeset
   504
 * \ingroup randomvariable
360
7bffd987426c Fixed major memory bug and docs in RandomVariable
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 346
diff changeset
   505
 *
346
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   506
 * 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
   507
 * 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
   508
 * 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
   509
 * 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
   510
 * the specified value.  When values are requested,
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   511
 * 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
   512
 * 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
   513
 * 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
   514
 * as inverse transform sampling:
f56860663c54 Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 2451
diff changeset
   515
 * (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
   516
 */
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   517
class EmpiricalVariable : public RandomVariable {
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   518
public:
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   519
  /**
2762
f56860663c54 Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 2451
diff changeset
   520
   * Constructor for the EmpiricalVariable random variables.
346
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   521
   */
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   522
  explicit EmpiricalVariable();
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   523
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   524
  /**
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   525
   * \brief Specifies a point in the empirical distribution
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   526
   * \param v The function value for this point
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   527
   * \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
   528
   */
2336
28ce210b91bb bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2217
diff changeset
   529
  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
   530
protected:
28ce210b91bb bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2217
diff changeset
   531
  EmpiricalVariable (const RandomVariableBase &variable);
346
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   532
};
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   533
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   534
/**
396
7b4349cd88bc add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 364
diff changeset
   535
 * \brief Integer-based empirical distribution
7b4349cd88bc add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 364
diff changeset
   536
 * \ingroup randomvariable
7b4349cd88bc add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 364
diff changeset
   537
 *
346
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   538
 * 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
   539
 * 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
   540
 * sampling interpolation described in the EmpiricalVariable documentation
f56860663c54 Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 2451
diff changeset
   541
 * is modified to only return integers.
346
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
class IntEmpiricalVariable : public EmpiricalVariable 
28ce210b91bb bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2217
diff changeset
   544
{
346
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   545
public:
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   546
  IntEmpiricalVariable();
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
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   549
/**
396
7b4349cd88bc add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 364
diff changeset
   550
 * \brief a non-random variable
7b4349cd88bc add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 364
diff changeset
   551
 * \ingroup randomvariable
7b4349cd88bc add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 364
diff changeset
   552
 *
7b4349cd88bc add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 364
diff changeset
   553
 * 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
   554
 * 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
   555
 * 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
   556
 * compare NS-3 to some other simulator
7b4349cd88bc add a randomvariable group
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 364
diff changeset
   557
 */
2336
28ce210b91bb bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2217
diff changeset
   558
class DeterministicVariable : public RandomVariable
28ce210b91bb bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2217
diff changeset
   559
{
346
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   560
public:
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
   * \brief Constructor
360
7bffd987426c Fixed major memory bug and docs in RandomVariable
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 346
diff changeset
   563
   *
346
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   564
   * 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
   565
   * 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
   566
   * 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
   567
   * 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
   568
   * of DeterministicVariable to be meaningful.
346
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   569
   * \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
   570
   * \param c Number of values in the array
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   571
   */
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   572
  explicit DeterministicVariable(double* d, uint32_t c);
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   573
};
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   574
438
515bb5663cf3 Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 423
diff changeset
   575
515bb5663cf3 Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 423
diff changeset
   576
/**
515bb5663cf3 Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 423
diff changeset
   577
 * \brief Log-normal Distributed random var
515bb5663cf3 Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 423
diff changeset
   578
 * \ingroup randomvariable
1872
4dfb2a623722 bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1806
diff changeset
   579
 *
2762
f56860663c54 Cleanup of RandomVariable doxygen (bug 110)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 2451
diff changeset
   580
 * LogNormalVariable defines a random variable with log-normal
438
515bb5663cf3 Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 423
diff changeset
   581
 * distribution.  If one takes the natural logarithm of random
515bb5663cf3 Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 423
diff changeset
   582
 * variable following the log-normal distribution, the obtained values
515bb5663cf3 Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 423
diff changeset
   583
 * follow a normal distribution.
442
96d3e7dc8bb2 Added static RNGs, like ExponentialVariable::GetSingleValue(mean)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 438
diff changeset
   584
 *  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
   585
 * 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
   586
 * 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
   587
 *
4dfb2a623722 bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1806
diff changeset
   588
 * 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
   589
 * \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
   590
 * 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
   591
 * \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
   592
 *
4dfb2a623722 bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1806
diff changeset
   593
 * 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
   594
 * 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
   595
 * \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
   596
 * \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
   597
 */
2336
28ce210b91bb bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2217
diff changeset
   598
class LogNormalVariable : public RandomVariable 
28ce210b91bb bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2217
diff changeset
   599
{
438
515bb5663cf3 Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 423
diff changeset
   600
public:
515bb5663cf3 Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 423
diff changeset
   601
  /**
1872
4dfb2a623722 bug 109: improve the doxygen documentation for RandomVariable
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1806
diff changeset
   602
   * \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
   603
   * \param sigma sigma parameter of the lognormal distribution
438
515bb5663cf3 Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 423
diff changeset
   604
   */
515bb5663cf3 Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 423
diff changeset
   605
  LogNormalVariable (double mu, double sigma);
515bb5663cf3 Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 423
diff changeset
   606
};
515bb5663cf3 Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 423
diff changeset
   607
942
b65368bf40f9 Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 676
diff changeset
   608
/**
b65368bf40f9 Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 676
diff changeset
   609
 * \brief Triangularly Distributed random var
b65368bf40f9 Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 676
diff changeset
   610
 * \ingroup randomvariable
b65368bf40f9 Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 676
diff changeset
   611
 * 
b65368bf40f9 Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 676
diff changeset
   612
 * 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
   613
 * is in the shape of a triangle.
b65368bf40f9 Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 676
diff changeset
   614
 */
2336
28ce210b91bb bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2217
diff changeset
   615
class TriangularVariable : public RandomVariable 
28ce210b91bb bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2217
diff changeset
   616
{
942
b65368bf40f9 Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 676
diff changeset
   617
public:
b65368bf40f9 Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 676
diff changeset
   618
  /**
b65368bf40f9 Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 676
diff changeset
   619
   * 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
   620
   * 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
   621
   */
b65368bf40f9 Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 676
diff changeset
   622
  TriangularVariable();
b65368bf40f9 Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 676
diff changeset
   623
b65368bf40f9 Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 676
diff changeset
   624
  /**
b65368bf40f9 Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 676
diff changeset
   625
   * 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
   626
   * range
b65368bf40f9 Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 676
diff changeset
   627
   * \param s Low end of the range
b65368bf40f9 Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 676
diff changeset
   628
   * \param l High end of the range
b65368bf40f9 Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 676
diff changeset
   629
   * \param mean mean of the distribution
b65368bf40f9 Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 676
diff changeset
   630
   */
b65368bf40f9 Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 676
diff changeset
   631
  TriangularVariable(double s, double l, double mean);
4218
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3267
diff changeset
   632
942
b65368bf40f9 Added Triangularly distributed random variables
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 676
diff changeset
   633
};
438
515bb5663cf3 Randomvariable Lognormal added
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 423
diff changeset
   634
2409
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2408
diff changeset
   635
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
   636
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
   637
2969
9d05d2a95dfa improve the auto-generated doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2965
diff changeset
   638
/**
9d05d2a95dfa improve the auto-generated doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2965
diff changeset
   639
 * \class ns3::RandomVariableValue
9d05d2a95dfa improve the auto-generated doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2965
diff changeset
   640
 * \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
   641
 */
9d05d2a95dfa improve the auto-generated doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2965
diff changeset
   642
2445
e1b65471f159 convert RandomVariable to new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2439
diff changeset
   643
ATTRIBUTE_VALUE_DEFINE (RandomVariable);
e1b65471f159 convert RandomVariable to new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2439
diff changeset
   644
ATTRIBUTE_CHECKER_DEFINE (RandomVariable);
e1b65471f159 convert RandomVariable to new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2439
diff changeset
   645
ATTRIBUTE_ACCESSOR_DEFINE (RandomVariable);
2384
500ada6a4874 add Value support to RandomVariable.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2336
diff changeset
   646
346
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   647
}//namespace ns3
2384
500ada6a4874 add Value support to RandomVariable.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2336
diff changeset
   648
500ada6a4874 add Value support to RandomVariable.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2336
diff changeset
   649
346
4a76f247e7dc Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   650
#endif