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