src/core/examples/main-random-variable.cc
author Tom Henderson <tomh@tomh.org>
Mon, 28 Sep 2015 20:27:25 -0700
changeset 11676 05ea1489e509
parent 8874 f5d7b689eae9
permissions -rw-r--r--
bug 2184: Integer overflow in MacLow
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7385
10beb0e53130 standardize emacs c++ mode comments
Vedran Miletić <rivanvx@gmail.com>
parents: 7256
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
     2
/*
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
     3
 * Copyright (c) 2008 Timo Bingmann
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
     4
 *
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
     8
 *
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    12
 * GNU General Public License for more details.
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    13
 *
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    17
 *
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    18
 * Author: Timo Bingmann <timo.bingmann@student.kit.edu>
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    19
 */
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
    20
#include "ns3/random-variable-stream.h"
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
    21
#include "ns3/ptr.h"
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
    22
#include "ns3/double.h"
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
    23
#include "ns3/string.h"
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
    24
#include "ns3/integer.h"
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    25
#include "ns3/gnuplot.h"
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    26
#include <map>
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    27
#include <cmath>
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    28
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    29
using namespace ns3;
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    30
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    31
/// Round a double number to the given precision. e.g. dround(0.234, 0.1) = 0.2
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    32
/// and dround(0.257, 0.1) = 0.3
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
    33
double dround (double number, double precision)
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    34
{
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    35
  number /= precision;
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    36
  if (number >= 0)
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
    37
    number = std::floor (number + 0.5);
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    38
  else
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
    39
    number = std::ceil (number - 0.5);
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    40
  number *= precision;
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    41
  return number;
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    42
}
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    43
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    44
static GnuplotDataset
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
    45
Histogramm (Ptr<RandomVariableStream> rndvar, unsigned int probes, double precision, const std::string& title, bool notcontinous = false)
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    46
{
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    47
  typedef std::map<double, unsigned int> histogramm_maptype;
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    48
  histogramm_maptype histogramm;
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    49
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    50
  for(unsigned int i = 0; i < probes; ++i)
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    51
    {
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
    52
      double val = dround ( rndvar->GetValue (), precision );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    53
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    54
      ++histogramm[val];
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    55
    }
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    56
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    57
  Gnuplot2dDataset data;
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
    58
  data.SetTitle (title);
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    59
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    60
  if (notcontinous)
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    61
    {
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
    62
      data.SetStyle (Gnuplot2dDataset::IMPULSES);
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    63
    }
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    64
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
    65
  for(histogramm_maptype::const_iterator hi = histogramm.begin ();
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
    66
      hi != histogramm.end (); ++hi)
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    67
    {
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
    68
      data.Add (hi->first, (double)hi->second / (double)probes / precision);
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    69
    }
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    70
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    71
  return data;
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    72
}
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    73
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    74
int main (int argc, char *argv[])
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    75
{
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    76
  unsigned int probes = 1000000;
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    77
  double precision = 0.01;
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    78
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
    79
  GnuplotCollection gnuplots ("main-random-variables.pdf");
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
    80
  gnuplots.SetTerminal ("pdf enhanced");
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    81
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    82
  {
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    83
    Gnuplot plot;
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
    84
    plot.SetTitle ("UniformRandomVariable");
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
    85
    plot.AppendExtra ("set yrange [0:]");
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    86
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
    87
    Ptr<UniformRandomVariable> x = CreateObject<UniformRandomVariable> ();
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
    88
    x->SetAttribute ("Min", DoubleValue (0.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
    89
    x->SetAttribute ("Max", DoubleValue (1.0));
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    90
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
    91
    plot.AddDataset ( Histogramm (x, probes, precision,
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
    92
                                  "UniformRandomVariable [0.0 .. 1.0)") );
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
    93
    plot.AddDataset ( Gnuplot2dFunction ("1.0",
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
    94
                                         "0 <= x && x <= 1 ? 1.0 : 0") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    95
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
    96
    gnuplots.AddPlot (plot);
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    97
  }
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    98
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
    99
  {
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   100
    Gnuplot plot;
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   101
    plot.SetTitle ("ExponentialRandomVariable");
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   102
    plot.AppendExtra ("set xrange [0:8]");
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   103
    plot.AppendExtra ("ExpDist(x,l) = 1/l * exp(-1/l * x)");
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   104
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   105
    Ptr<ExponentialRandomVariable> x1 = CreateObject<ExponentialRandomVariable> ();
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   106
    x1->SetAttribute ("Mean", DoubleValue (0.5));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   107
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   108
    plot.AddDataset ( Histogramm (x1, probes, precision,
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   109
                                  "ExponentialRandomVariable m=0.5") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   110
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   111
    plot.AddDataset ( Gnuplot2dFunction ("ExponentialDistribution mean 0.5",
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   112
                                         "ExpDist(x, 0.5)") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   113
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   114
    Ptr<ExponentialRandomVariable> x2 = CreateObject<ExponentialRandomVariable> ();
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   115
    x2->SetAttribute ("Mean", DoubleValue (1.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   116
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   117
    plot.AddDataset ( Histogramm (x2, probes, precision,
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   118
                                  "ExponentialRandomVariable m=1") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   119
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   120
    plot.AddDataset ( Gnuplot2dFunction ("ExponentialDistribution mean 1.0",
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   121
                                         "ExpDist(x, 1.0)") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   122
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   123
    Ptr<ExponentialRandomVariable> x3 = CreateObject<ExponentialRandomVariable> ();
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   124
    x3->SetAttribute ("Mean", DoubleValue (1.5));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   125
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   126
    plot.AddDataset ( Histogramm (x3, probes, precision,
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   127
                                  "ExponentialRandomVariable m=1.5") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   128
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   129
    plot.AddDataset ( Gnuplot2dFunction ("ExponentialDistribution mean 1.5",
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   130
                                         "ExpDist(x, 1.5)") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   131
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   132
    gnuplots.AddPlot (plot);
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   133
  }
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   134
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   135
  {
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   136
    Gnuplot plot;
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   137
    plot.SetTitle ("ParetoRandomVariable");
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   138
    plot.AppendExtra ("set xrange [0:2]");
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   139
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   140
    Ptr<ParetoRandomVariable> x1 = CreateObject<ParetoRandomVariable> ();
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   141
    x1->SetAttribute ("Mean", DoubleValue (1.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   142
    x1->SetAttribute ("Shape", DoubleValue (1.5));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   143
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   144
    plot.AddDataset ( Histogramm (x1, probes, precision,
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   145
                                  "ParetoRandomVariable m=1.0 s=1.5") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   146
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   147
    Ptr<ParetoRandomVariable> x2 = CreateObject<ParetoRandomVariable> ();
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   148
    x2->SetAttribute ("Mean", DoubleValue (1.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   149
    x2->SetAttribute ("Shape", DoubleValue (2.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   150
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   151
    plot.AddDataset ( Histogramm (x2, probes, precision,
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   152
                                  "ParetoRandomVariable m=1.0 s=2.0") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   153
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   154
    Ptr<ParetoRandomVariable> x3 = CreateObject<ParetoRandomVariable> ();
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   155
    x3->SetAttribute ("Mean", DoubleValue (1.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   156
    x3->SetAttribute ("Shape", DoubleValue (2.5));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   157
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   158
    plot.AddDataset ( Histogramm (x3, probes, precision,
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   159
                                  "ParetoRandomVariable m=1.0 s=2.5") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   160
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   161
    gnuplots.AddPlot (plot);
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   162
  }
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   163
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   164
  {
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   165
    Gnuplot plot;
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   166
    plot.SetTitle ("WeibullRandomVariable");
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   167
    plot.AppendExtra ("set xrange [0:3]");
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   168
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   169
    Ptr<WeibullRandomVariable> x1 = CreateObject<WeibullRandomVariable> ();
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   170
    x1->SetAttribute ("Scale", DoubleValue (1.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   171
    x1->SetAttribute ("Shape", DoubleValue (1.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   172
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   173
    plot.AddDataset ( Histogramm (x1, probes, precision,
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   174
                                  "WeibullRandomVariable m=1.0 s=1.0") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   175
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   176
    Ptr<WeibullRandomVariable> x2 = CreateObject<WeibullRandomVariable> ();
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   177
    x2->SetAttribute ("Scale", DoubleValue (1.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   178
    x2->SetAttribute ("Shape", DoubleValue (2.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   179
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   180
    plot.AddDataset ( Histogramm (x2, probes, precision,
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   181
                                  "WeibullRandomVariable m=1.0 s=2.0") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   182
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   183
    Ptr<WeibullRandomVariable> x3 = CreateObject<WeibullRandomVariable> ();
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   184
    x3->SetAttribute ("Scale", DoubleValue (1.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   185
    x3->SetAttribute ("Shape", DoubleValue (3.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   186
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   187
    plot.AddDataset ( Histogramm (x3, probes, precision,
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   188
                                  "WeibullRandomVariable m=1.0 s=3.0") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   189
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   190
    gnuplots.AddPlot (plot);
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   191
  }
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   192
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   193
  {
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   194
    Gnuplot plot;
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   195
    plot.SetTitle ("NormalRandomVariable");
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   196
    plot.AppendExtra ("set xrange [-3:3]");
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   197
    plot.AppendExtra ("NormalDist(x,m,s) = 1 / (s * sqrt(2*pi)) * exp(-1.0 / 2.0 * ((x-m) / s)**2)");
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   198
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   199
    Ptr<NormalRandomVariable> x1 = CreateObject<NormalRandomVariable> ();
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   200
    x1->SetAttribute ("Mean", DoubleValue (0.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   201
    x1->SetAttribute ("Variance", DoubleValue (1.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   202
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   203
    plot.AddDataset ( Histogramm (x1, probes, precision,
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   204
                                  "NormalRandomVariable m=0.0 v=1.0") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   205
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   206
    plot.AddDataset ( Gnuplot2dFunction ("NormalDist {/Symbol m}=0.0 {/Symbol s}=1.0",
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   207
                                         "NormalDist(x,0.0,1.0)") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   208
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   209
    Ptr<NormalRandomVariable> x2 = CreateObject<NormalRandomVariable> ();
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   210
    x2->SetAttribute ("Mean", DoubleValue (0.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   211
    x2->SetAttribute ("Variance", DoubleValue (2.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   212
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   213
    plot.AddDataset ( Histogramm (x2, probes, precision,
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   214
                                  "NormalRandomVariable m=0.0 v=2.0") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   215
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   216
    plot.AddDataset ( Gnuplot2dFunction ("NormalDist {/Symbol m}=0.0 {/Symbol s}=sqrt(2.0)",
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   217
                                         "NormalDist(x,0.0,sqrt(2.0))") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   218
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   219
    Ptr<NormalRandomVariable> x3 = CreateObject<NormalRandomVariable> ();
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   220
    x3->SetAttribute ("Mean", DoubleValue (0.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   221
    x3->SetAttribute ("Variance", DoubleValue (3.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   222
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   223
    plot.AddDataset ( Histogramm (x3, probes, precision,
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   224
                                  "NormalRandomVariable m=0.0 v=3.0") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   225
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   226
    plot.AddDataset ( Gnuplot2dFunction ("NormalDist {/Symbol m}=0.0 {/Symbol s}=sqrt(3.0)",
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   227
                                         "NormalDist(x,0.0,sqrt(3.0))") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   228
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   229
    gnuplots.AddPlot (plot);
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   230
  }
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   231
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   232
  {
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   233
    Gnuplot plot;
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   234
    plot.SetTitle ("EmpiricalRandomVariable");
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   235
    plot.AppendExtra ("set xrange [*:*]");
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   236
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   237
    Ptr<EmpiricalRandomVariable> emp1 = CreateObject<EmpiricalRandomVariable> ();
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   238
    emp1->CDF (0.0,  0.0 / 15.0);
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   239
    emp1->CDF (0.2,  1.0 / 15.0);
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   240
    emp1->CDF (0.4,  3.0 / 15.0);
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   241
    emp1->CDF (0.6,  6.0 / 15.0);
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   242
    emp1->CDF (0.8, 10.0 / 15.0);
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   243
    emp1->CDF (1.0, 15.0 / 15.0);
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   244
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   245
    plot.AddDataset ( Histogramm (emp1, probes, precision,
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   246
                                  "EmpiricalRandomVariable (Stairs)") );
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   247
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   248
    gnuplots.AddPlot (plot);
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   249
  }
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   250
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   251
  {
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   252
    Gnuplot plot;
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   253
    plot.SetTitle ("DeterministicRandomVariable");
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   254
    plot.AppendExtra ("set xrange [*:*]");
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   255
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   256
    double values[] = { 0.0, 0.2, 0.2, 0.4, 0.2, 0.6, 0.8, 0.8, 1.0 };
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   257
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   258
    Ptr<DeterministicRandomVariable> det1 = CreateObject<DeterministicRandomVariable> ();
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   259
    det1->SetValueArray (values, sizeof(values) / sizeof(values[0]));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   260
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   261
    plot.AddDataset ( Histogramm (det1, probes, precision,
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   262
                                  "DeterministicRandomVariable", true) );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   263
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   264
    gnuplots.AddPlot (plot);
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   265
  }
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   266
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   267
  {
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   268
    Gnuplot plot;
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   269
    plot.SetTitle ("LogNormalRandomVariable");
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   270
    plot.AppendExtra ("set xrange [0:3]");
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   271
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   272
    plot.AppendExtra ("LogNormalDist(x,m,s) = 1.0/x * NormalDist(log(x), m, s)");
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   273
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   274
    Ptr<LogNormalRandomVariable> x1 = CreateObject<LogNormalRandomVariable> ();
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   275
    x1->SetAttribute ("Mu", DoubleValue (0.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   276
    x1->SetAttribute ("Sigma", DoubleValue (1.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   277
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   278
    plot.AddDataset ( Histogramm (x1, probes, precision,
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   279
                                  "LogNormalRandomVariable m=0.0 s=1.0") );
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   280
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   281
    plot.AddDataset ( Gnuplot2dFunction ("LogNormalDist(x, 0.0, 1.0)",
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   282
                                         "LogNormalDist(x, 0.0, 1.0)") );
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   283
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   284
    Ptr<LogNormalRandomVariable> x2 = CreateObject<LogNormalRandomVariable> ();
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   285
    x2->SetAttribute ("Mu", DoubleValue (0.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   286
    x2->SetAttribute ("Sigma", DoubleValue (0.5));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   287
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   288
    plot.AddDataset ( Histogramm (x2, probes, precision,
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   289
                                  "LogNormalRandomVariable m=0.0 s=0.5") );
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   290
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   291
    Ptr<LogNormalRandomVariable> x3 = CreateObject<LogNormalRandomVariable> ();
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   292
    x3->SetAttribute ("Mu", DoubleValue (0.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   293
    x3->SetAttribute ("Sigma", DoubleValue (0.25));
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   294
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   295
    plot.AddDataset ( Histogramm (x3, probes, precision,
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   296
                                  "LogNormalRandomVariable m=0.0 s=0.25") );
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   297
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   298
    plot.AddDataset ( Gnuplot2dFunction ("LogNormalDist(x, 0.0, 0.25)",
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   299
                                         "LogNormalDist(x, 0.0, 0.25)") );
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   300
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   301
    Ptr<LogNormalRandomVariable> x4 = CreateObject<LogNormalRandomVariable> ();
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   302
    x4->SetAttribute ("Mu", DoubleValue (0.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   303
    x4->SetAttribute ("Sigma", DoubleValue (0.125));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   304
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   305
    plot.AddDataset ( Histogramm (x4, probes, precision,
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   306
                                  "LogNormalRandomVariable m=0.0 s=0.125") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   307
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   308
    Ptr<LogNormalRandomVariable> x5 = CreateObject<LogNormalRandomVariable> ();
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   309
    x5->SetAttribute ("Mu", DoubleValue (0.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   310
    x5->SetAttribute ("Sigma", DoubleValue (2.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   311
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   312
    plot.AddDataset ( Histogramm (x5, probes, precision,
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   313
                                  "LogNormalRandomVariable m=0.0 s=2.0") );
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   314
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   315
    plot.AddDataset ( Gnuplot2dFunction ("LogNormalDist(x, 0.0, 2.0)",
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   316
                                         "LogNormalDist(x, 0.0, 2.0)") );
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   317
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   318
    Ptr<LogNormalRandomVariable> x6 = CreateObject<LogNormalRandomVariable> ();
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   319
    x6->SetAttribute ("Mu", DoubleValue (0.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   320
    x6->SetAttribute ("Sigma", DoubleValue (2.5));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   321
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   322
    plot.AddDataset ( Histogramm (x6, probes, precision,
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   323
                                  "LogNormalRandomVariable m=0.0 s=2.5") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   324
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   325
    gnuplots.AddPlot (plot);
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   326
  }
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   327
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   328
  {
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   329
    Gnuplot plot;
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   330
    plot.SetTitle ("TriangularRandomVariable");
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   331
    plot.AppendExtra ("set xrange [*:*]");
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   332
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   333
    Ptr<TriangularRandomVariable> x1 = CreateObject<TriangularRandomVariable> ();
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   334
    x1->SetAttribute ("Min", DoubleValue (0.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   335
    x1->SetAttribute ("Max", DoubleValue (1.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   336
    x1->SetAttribute ("Mean", DoubleValue (0.5));
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   337
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   338
    plot.AddDataset ( Histogramm (x1, probes, precision,
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   339
                                  "TriangularRandomVariable [0.0 .. 1.0) m=0.5") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   340
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   341
    Ptr<TriangularRandomVariable> x2 = CreateObject<TriangularRandomVariable> ();
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   342
    x2->SetAttribute ("Min", DoubleValue (0.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   343
    x2->SetAttribute ("Max", DoubleValue (1.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   344
    x2->SetAttribute ("Mean", DoubleValue (0.4));
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   345
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   346
    plot.AddDataset ( Histogramm (x2, probes, precision,
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   347
                                  "TriangularRandomVariable [0.0 .. 1.0) m=0.4") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   348
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   349
    Ptr<TriangularRandomVariable> x3 = CreateObject<TriangularRandomVariable> ();
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   350
    x3->SetAttribute ("Min", DoubleValue (0.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   351
    x3->SetAttribute ("Max", DoubleValue (1.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   352
    x3->SetAttribute ("Mean", DoubleValue (0.65));
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   353
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   354
    plot.AddDataset ( Histogramm (x3, probes, precision,
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   355
                                  "TriangularRandomVariable [0.0 .. 1.0) m=0.65") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   356
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   357
    gnuplots.AddPlot (plot);
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   358
  }
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   359
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   360
  {
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   361
    Gnuplot plot;
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   362
    plot.SetTitle ("GammaRandomVariable");
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   363
    plot.AppendExtra ("set xrange [0:10]");
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   364
    plot.AppendExtra ("set yrange [0:1]");
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   365
    plot.AppendExtra ("GammaDist(x,a,b) = x**(a-1) * 1/b**a * exp(-x/b) / gamma(a)");
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   366
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   367
    plot.AppendExtra ("set label 1 '{/Symbol g}(x,{/Symbol a},{/Symbol b}) = x^{/Symbol a-1} e^{-x {/Symbol b}^{-1}} ( {/Symbol b}^{/Symbol a} {/Symbol G}({/Symbol a}) )^{-1}' at 0.7, 0.9");
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   368
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   369
    Ptr<GammaRandomVariable> x1 = CreateObject<GammaRandomVariable> ();
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   370
    x1->SetAttribute ("Alpha", DoubleValue (1.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   371
    x1->SetAttribute ("Beta", DoubleValue (1.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   372
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   373
    plot.AddDataset ( Histogramm (x1, probes, precision,
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   374
                                  "GammaRandomVariable a=1.0 b=1.0") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   375
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   376
    plot.AddDataset ( Gnuplot2dFunction ("{/Symbol g}(x, 1.0, 1.0)",
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   377
                                         "GammaDist(x, 1.0, 1.0)") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   378
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   379
    Ptr<GammaRandomVariable> x2 = CreateObject<GammaRandomVariable> ();
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   380
    x2->SetAttribute ("Alpha", DoubleValue (1.5));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   381
    x2->SetAttribute ("Beta", DoubleValue (1.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   382
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   383
    plot.AddDataset ( Histogramm (x2, probes, precision,
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   384
                                  "GammaRandomVariable a=1.5 b=1.0") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   385
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   386
    plot.AddDataset ( Gnuplot2dFunction ("{/Symbol g}(x, 1.5, 1.0)",
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   387
                                         "GammaDist(x, 1.5, 1.0)") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   388
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   389
    Ptr<GammaRandomVariable> x3 = CreateObject<GammaRandomVariable> ();
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   390
    x3->SetAttribute ("Alpha", DoubleValue (2.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   391
    x3->SetAttribute ("Beta", DoubleValue (1.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   392
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   393
    plot.AddDataset ( Histogramm (x3, probes, precision,
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   394
                                  "GammaRandomVariable a=2.0 b=1.0") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   395
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   396
    plot.AddDataset ( Gnuplot2dFunction ("{/Symbol g}(x, 2.0, 1.0)",
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   397
                                         "GammaDist(x, 2.0, 1.0)") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   398
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   399
    Ptr<GammaRandomVariable> x4 = CreateObject<GammaRandomVariable> ();
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   400
    x4->SetAttribute ("Alpha", DoubleValue (4.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   401
    x4->SetAttribute ("Beta", DoubleValue (1.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   402
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   403
    plot.AddDataset ( Histogramm (x4, probes, precision,
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   404
                                  "GammaRandomVariable a=4.0 b=1.0") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   405
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   406
    plot.AddDataset ( Gnuplot2dFunction ("{/Symbol g}(x, 4.0, 1.0)",
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   407
                                         "GammaDist(x, 4.0, 1.0)") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   408
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   409
    Ptr<GammaRandomVariable> x5 = CreateObject<GammaRandomVariable> ();
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   410
    x5->SetAttribute ("Alpha", DoubleValue (2.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   411
    x5->SetAttribute ("Beta", DoubleValue (2.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   412
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   413
    plot.AddDataset ( Histogramm (x5, probes, precision,
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   414
                                  "GammaRandomVariable a=2.0 b=2.0") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   415
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   416
    plot.AddDataset ( Gnuplot2dFunction ("{/Symbol g}(x, 2.0, 2.0)",
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   417
                                         "GammaDist(x, 2.0, 2.0)") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   418
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   419
    Ptr<GammaRandomVariable> x6 = CreateObject<GammaRandomVariable> ();
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   420
    x6->SetAttribute ("Alpha", DoubleValue (2.5));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   421
    x6->SetAttribute ("Beta", DoubleValue (3.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   422
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   423
    plot.AddDataset ( Histogramm (x6, probes, precision,
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   424
                                  "GammaRandomVariable a=2.5 b=3.0") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   425
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   426
    plot.AddDataset ( Gnuplot2dFunction ("{/Symbol g}(x, 2.5, 3.0)",
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   427
                                         "GammaDist(x, 2.5, 3.0)") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   428
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   429
    Ptr<GammaRandomVariable> x7 = CreateObject<GammaRandomVariable> ();
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   430
    x7->SetAttribute ("Alpha", DoubleValue (2.5));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   431
    x7->SetAttribute ("Beta", DoubleValue (4.5));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   432
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   433
    plot.AddDataset ( Histogramm (x7, probes, precision,
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   434
                                  "GammaRandomVariable a=2.5 b=4.5") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   435
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   436
    plot.AddDataset ( Gnuplot2dFunction ("{/Symbol g}(x, 2.5, 4.5)",
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   437
                                         "GammaDist(x, 2.5, 4.5)") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   438
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   439
    gnuplots.AddPlot (plot);
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   440
  }
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   441
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   442
  {
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   443
    Gnuplot plot;
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   444
    plot.SetTitle ("ErlangRandomVariable");
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   445
    plot.AppendExtra ("set xrange [0:10]");
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   446
    plot.AppendExtra ("ErlangDist(x,k,l) = x**(k-1) * 1/l**k * exp(-x/l) / (k-1)!");
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   447
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   448
    plot.AppendExtra ("set label 1 'Erlang(x,k,{/Symbol l}) = x^{k-1} e^{-x {/Symbol l}^{-1}} ( {/Symbol l}^k (k-1)! )^{-1}' at 0.7, 0.9");
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   449
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   450
    Ptr<ErlangRandomVariable> x1 = CreateObject<ErlangRandomVariable> ();
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   451
    x1->SetAttribute ("K", IntegerValue (1));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   452
    x1->SetAttribute ("Lambda", DoubleValue (1.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   453
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   454
    plot.AddDataset ( Histogramm (x1, probes, precision,
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   455
                                  "ErlangRandomVariable k=1 {/Symbol l}=1.0") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   456
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   457
    plot.AddDataset ( Gnuplot2dFunction ("Erlang(x, 1, 1.0)",
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   458
                                         "ErlangDist(x, 1, 1.0)") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   459
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   460
    Ptr<ErlangRandomVariable> x2 = CreateObject<ErlangRandomVariable> ();
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   461
    x2->SetAttribute ("K", IntegerValue (2));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   462
    x2->SetAttribute ("Lambda", DoubleValue (1.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   463
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   464
    plot.AddDataset ( Histogramm (x2, probes, precision,
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   465
                                  "ErlangRandomVariable k=2 {/Symbol l}=1.0") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   466
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   467
    plot.AddDataset ( Gnuplot2dFunction ("Erlang(x, 2, 1.0)",
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   468
                                         "ErlangDist(x, 2, 1.0)") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   469
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   470
    Ptr<ErlangRandomVariable> x3 = CreateObject<ErlangRandomVariable> ();
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   471
    x3->SetAttribute ("K", IntegerValue (3));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   472
    x3->SetAttribute ("Lambda", DoubleValue (1.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   473
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   474
    plot.AddDataset ( Histogramm (x3, probes, precision,
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   475
                                  "ErlangRandomVariable k=3 {/Symbol l}=1.0") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   476
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   477
    plot.AddDataset ( Gnuplot2dFunction ("Erlang(x, 3, 1.0)",
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   478
                                         "ErlangDist(x, 3, 1.0)") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   479
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   480
    Ptr<ErlangRandomVariable> x4 = CreateObject<ErlangRandomVariable> ();
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   481
    x4->SetAttribute ("K", IntegerValue (5));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   482
    x4->SetAttribute ("Lambda", DoubleValue (1.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   483
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   484
    plot.AddDataset ( Histogramm (x4, probes, precision,
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   485
                                  "ErlangRandomVariable k=5 {/Symbol l}=1.0") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   486
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   487
    plot.AddDataset ( Gnuplot2dFunction ("Erlang(x, 5, 1.0)",
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   488
                                         "ErlangDist(x, 5, 1.0)") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   489
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   490
    Ptr<ErlangRandomVariable> x5 = CreateObject<ErlangRandomVariable> ();
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   491
    x5->SetAttribute ("K", IntegerValue (2));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   492
    x5->SetAttribute ("Lambda", DoubleValue (2.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   493
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   494
    plot.AddDataset ( Histogramm (x5, probes, precision,
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   495
                                  "ErlangRandomVariable k=2 {/Symbol l}=2.0") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   496
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   497
    plot.AddDataset ( Gnuplot2dFunction ("Erlang(x, 2, 2.0)",
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   498
                                         "ErlangDist(x, 2, 2.0)") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   499
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   500
    Ptr<ErlangRandomVariable> x6 = CreateObject<ErlangRandomVariable> ();
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   501
    x6->SetAttribute ("K", IntegerValue (2));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   502
    x6->SetAttribute ("Lambda", DoubleValue (3.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   503
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   504
    plot.AddDataset ( Histogramm (x6, probes, precision,
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   505
                                  "ErlangRandomVariable k=2 {/Symbol l}=3.0") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   506
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   507
    plot.AddDataset ( Gnuplot2dFunction ("Erlang(x, 2, 3.0)",
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   508
                                         "ErlangDist(x, 2, 3.0)") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   509
8874
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   510
    Ptr<ErlangRandomVariable> x7 = CreateObject<ErlangRandomVariable> ();
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   511
    x7->SetAttribute ("K", IntegerValue (2));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   512
    x7->SetAttribute ("Lambda", DoubleValue (5.0));
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   513
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   514
    plot.AddDataset ( Histogramm (x7, probes, precision,
f5d7b689eae9 examples for RandomVariableStream implementations
Mitch Watrous <watrous@u.washington.edu>
parents: 7385
diff changeset
   515
                                  "ErlangRandomVariable k=2 {/Symbol l}=5.0") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   516
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   517
    plot.AddDataset ( Gnuplot2dFunction ("Erlang(x, 2, 5.0)",
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   518
                                         "ErlangDist(x, 2, 5.0)") );
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   519
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   520
    gnuplots.AddPlot (plot);
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   521
  }
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   522
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   523
  gnuplots.GenerateOutput (std::cout);
4317
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   524
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   525
  return 0;
0a250f44e0ed bug 475: GammaVariable and ErlangVariable
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
diff changeset
   526
}