-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdistributions.html
317 lines (289 loc) · 18.7 KB
/
distributions.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Continuous Distributions Reference — Semi-Markov 1.0 documentation</title>
<link rel="stylesheet" href="_static/sphinxdoc.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '1.0',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<link rel="top" title="Semi-Markov 1.0 documentation" href="index.html" />
<link rel="up" title="Semi-Markov Library Reference" href="reference.html" />
<link rel="next" title="Dynamics Reference" href="dynamics.html" />
<link rel="prev" title="Marking Reference" href="marking.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="dynamics.html" title="Dynamics Reference"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="marking.html" title="Marking Reference"
accesskey="P">previous</a> |</li>
<li><a href="index.html">Semi-Markov 1.0 documentation</a> »</li>
<li><a href="reference.html" accesskey="U">Semi-Markov Library Reference</a> »</li>
</ul>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Continuous Distributions Reference</a><ul>
<li><a class="reference internal" href="#transitiondistribution-base-class">TransitionDistribution Base Class</a></li>
<li><a class="reference internal" href="#exponential-distribution">Exponential Distribution</a></li>
<li><a class="reference internal" href="#weibull-distribution">Weibull Distribution</a></li>
<li><a class="reference internal" href="#gamma-distribution">Gamma Distribution</a></li>
<li><a class="reference internal" href="#piecewise-linear-distribution">Piecewise Linear Distribution</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="marking.html"
title="previous chapter">Marking Reference</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="dynamics.html"
title="next chapter">Dynamics Reference</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/distributions.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="continuous-distributions-reference">
<h1>Continuous Distributions Reference<a class="headerlink" href="#continuous-distributions-reference" title="Permalink to this headline">¶</a></h1>
<p>The core matrix of a semi-Markov system is defined on a joint
discrete and continuous space, where the discrete set is of
next possible states of the system and the continuous space
is of the next times when the system arrives at that state.
A competing process description of a semi-Markov system,
describes decides which state is next and when that state
happens by asking which of a set of continuous distributions,
one per competing process, is next to fire.</p>
<p>The GSPN, in particular, decides that, at the moment a transition
first becomes enabled by the marking, it chooses the distribution
of firing times. At any later time when a different, independent,
transition has fired without affecting the first, the first’s
distribution doesn’t change. It just gets renormalized to account
for knowledge that it has not yet fired. If we label the
cumulative distribution by <span class="math">\(F(t)\)</span> and a distribution is shifted
by a time <span class="math">\(\Delta=t_0-t_e\)</span>, then the new distribution is
sampled with a shifted quantile. If we know the original cumulative
distribution function, <span class="math">\(F(t,t_e),\)</span> where <span class="math">\(t_e\)</span> is the
enabling time of the distribution function, then we can calulate
the distribution, <em>given that it hasn’t fired before time</em> <span class="math">\(t_0\)</span>,
with</p>
<div class="math">
\[F(t, t_0, t_e)=\frac{F(t,t_e)-F(t_0,t_e)}{1-F(t_0,t_e)}\]</div>
<p>This makes the calculation of the quantile, using the original
quantile, <span class="math">\(F^{-1},\)</span> look like</p>
<div class="math">
\[t-t_0=Q(U,\Delta)=F^{-1}(U(1-F(\Delta))+F(\Delta))-\Delta.\]</div>
<p>Given any distributions from Boost::Random or std::random, this
formula calculates the shifted quantile from the original quantile
and cumulative distribution.</p>
<div class="section" id="transitiondistribution-base-class">
<h2>TransitionDistribution Base Class<a class="headerlink" href="#transitiondistribution-base-class" title="Permalink to this headline">¶</a></h2>
<p>Transitions for this library implement the following interface.</p>
<dl class="class">
<dt id="afidd::smv::TransitionDistribution:RandomGenerator:">
<em class="property">class </em><tt class="descclassname">afidd::smv::</tt><tt class="descname">TransitionDistribution<RandomGenerator></tt><a class="headerlink" href="#afidd::smv::TransitionDistribution:RandomGenerator:" title="Permalink to this definition">¶</a></dt>
<dd><p>This is the pure virtual base class for distributions.</p>
</dd></dl>
<dl class="function">
<dt id="Sample__double.RandomGeneratorRC">
double <tt class="descname">Sample</tt><big>(</big>double <em>current_time</em>, RandomGenerator& <em>rng</em><big>)</big><tt class="descclassname"> const</tt><a class="headerlink" href="#Sample__double.RandomGeneratorRC" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a sample from the random variable in absolute time
after the given current time.</p>
</dd></dl>
<dl class="function">
<dt id="EnablingTimeC">
double <tt class="descname">EnablingTime</tt><big>(</big><big>)</big><tt class="descclassname"> const</tt><a class="headerlink" href="#EnablingTimeC" title="Permalink to this definition">¶</a></dt>
<dd><p>Each distribution remembers its enabling time in absolute time
since the start of the simulation.</p>
</dd></dl>
<dl class="function">
<dt id="BoundedHazardC">
bool <tt class="descname">BoundedHazard</tt><big>(</big><big>)</big><tt class="descclassname"> const</tt><a class="headerlink" href="#BoundedHazardC" title="Permalink to this definition">¶</a></dt>
<dd><p>Some distributions have a hazard function, defined as the ratio
of the probability density to the survival, which is bounded for
finite times. These functions will have a well-defined hazard
integral. This method tells the caller whether the hazard integral
is a reasonable approach to sample the distribution.</p>
</dd></dl>
<dl class="function">
<dt id="HazardIntegral__double.doubleC">
double <tt class="descname">HazardIntegral</tt><big>(</big>double <em>t0</em>, double <em>t1</em><big>)</big><tt class="descclassname"> const</tt><a class="headerlink" href="#HazardIntegral__double.doubleC" title="Permalink to this definition">¶</a></dt>
<dd><p>This returns the integral of the hazard between absolute time
<span class="math">\(t_0\)</span> and <span class="math">\(t_1\)</span>.</p>
</dd></dl>
<dl class="function">
<dt id="ImplicitHazardIntegral__double.doubleC">
double <tt class="descname">ImplicitHazardIntegral</tt><big>(</big>double <em>xa</em>, double <em>t0</em><big>)</big><tt class="descclassname"> const</tt><a class="headerlink" href="#ImplicitHazardIntegral__double.doubleC" title="Permalink to this definition">¶</a></dt>
<dd><p>This implicitly solves for a quantile by integrating the hazard.
For certain distributions, this is analytic. The function returns
<span class="math">\(t\)</span> in</p>
</dd></dl>
<div class="math">
\[x_a=\int_{t_0}^{t} \lambda(s) ds.\]</div>
<p>The template argument RandomGenerator fulfills the concept of the Boost
random number generator concept and the std::random random number
generator concept.
Each sample can be taken from the difference between the two times,
<span class="math">\((t_c-t_e)\)</span>, but passing both separately will be better for vectorization
of sampling.</p>
<p>The following distributions are currently in the library.</p>
</div>
<div class="section" id="exponential-distribution">
<h2>Exponential Distribution<a class="headerlink" href="#exponential-distribution" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="afidd::smv::ExponentialDistribution:RandomNumberGenerator:">
<em class="property">class </em><tt class="descclassname">afidd::smv::</tt><tt class="descname">ExponentialDistribution<RandomNumberGenerator></tt><a class="headerlink" href="#afidd::smv::ExponentialDistribution:RandomNumberGenerator:" title="Permalink to this definition">¶</a></dt>
<dd><p>The <a class="reference external" href="http://en.wikipedia.org/wiki/Exponential_distribution">exponential distribution</a>
is the classic Markovian distribution. The cumulative
distribution and quantile are defined as the following.</p>
</dd></dl>
<div class="math">
\[F(x) = 1-e^{-λx}\]\[Q(x) = -(1/\lambda)\ln(1-x)\]\[Q(x,\Delta)=Q(x)\]</div>
<dl class="function">
<dt id="afidd::smv::ExponentialDistribution::ExponentialDistribution__double.double">
<tt class="descclassname">afidd::smv::ExponentialDistribution::</tt><tt class="descname">ExponentialDistribution</tt><big>(</big>double <em>lambda</em>, double <em>enabling_time</em><big>)</big><a class="headerlink" href="#afidd::smv::ExponentialDistribution::ExponentialDistribution__double.double" title="Permalink to this definition">¶</a></dt>
<dd><p>The constructor takes the parameter <cite>lambda,</cite> an enabling time for the
distribution as an absolute system time.</p>
</dd></dl>
<dl class="class">
<dt id="afidd::smv::ShiftedExponentialDistribution:RandomNumberGenerator:">
<em class="property">class </em><tt class="descclassname">afidd::smv::</tt><tt class="descname">ShiftedExponentialDistribution<RandomNumberGenerator></tt><a class="headerlink" href="#afidd::smv::ShiftedExponentialDistribution:RandomNumberGenerator:" title="Permalink to this definition">¶</a></dt>
<dd><p>The <a class="reference external" href="http://en.wikipedia.org/wiki/Exponential_distribution">exponential distribution</a>
is the classic Markovian distribution.
The shift is a displacement
of the cumulative distribution function by an amount <span class="math">\(t_s.\)</span></p>
</dd></dl>
<div class="math">
\[F(x) = 1-e^{-λ(x-t_s)}\]</div>
<dl class="function">
<dt id="afidd::smv::ShiftedExponentialDistribution::ExponentialDistribution__double.double.double.double">
<tt class="descclassname">afidd::smv::ShiftedExponentialDistribution::</tt><tt class="descname">ExponentialDistribution</tt><big>(</big>double <em>lambda</em>, double <em>enabling_time</em>, double <em>shift</em><em>=0.0</em>, double <em>normal</em><em>=1.0</em><big>)</big><a class="headerlink" href="#afidd::smv::ShiftedExponentialDistribution::ExponentialDistribution__double.double.double.double" title="Permalink to this definition">¶</a></dt>
<dd><p>The constructor takes the parameter <cite>lambda,</cite> an enabling time for the
distribution as an absolute system time, and a normalization constant.
If <cite>normal</cite> is less than one, it represents the probability that
this distribution will fire at all.</p>
</dd></dl>
</div>
<div class="section" id="weibull-distribution">
<h2>Weibull Distribution<a class="headerlink" href="#weibull-distribution" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="afidd::smv::WeibullDistribution:RandomNumberGenerator:">
<em class="property">class </em><tt class="descclassname">afidd::smv::</tt><tt class="descname">WeibullDistribution<RandomNumberGenerator></tt><a class="headerlink" href="#afidd::smv::WeibullDistribution:RandomNumberGenerator:" title="Permalink to this definition">¶</a></dt>
<dd><p><a class="reference external" href="http://en.wikipedia.org/wiki/Weibull_distribution">Weibull distributions</a> can model either infant mortality or aging processes. Parameters
may be defined different ways. This class uses the following
cumulative distribution and quantile.</p>
</dd></dl>
<div class="math">
\[F(x)=1-e^{-\left(x/\lambda\right)^k}\]\[Q(p; k,\lambda)=\lambda\left[-\ln(1-p)\right]^{1/k}\]\[Q(p,\Delta; k,\lambda)=\lambda\left[-\ln(1-p)+\left(\Delta/\lambda\right)^k\right]^{1/k}-\Delta\]</div>
<dl class="function">
<dt id="afidd::smv::WeibullDistribution::WeibullDistribution__double.double.double.double.double">
<tt class="descclassname">afidd::smv::WeibullDistribution::</tt><tt class="descname">WeibullDistribution</tt><big>(</big>double <em>lambda</em>, double <em>k</em>, double <em>enabling_time</em>, double <em>shift</em>, double <em>normal</em><em>=1.0</em><big>)</big><a class="headerlink" href="#afidd::smv::WeibullDistribution::WeibullDistribution__double.double.double.double.double" title="Permalink to this definition">¶</a></dt>
<dd><p>This creates a Weibull distribution with parameters as defined above.
The shift moves the distribution to the right.</p>
</dd></dl>
</div>
<div class="section" id="gamma-distribution">
<h2>Gamma Distribution<a class="headerlink" href="#gamma-distribution" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="afidd::smv::GammaDistribution:RandomNumberGenerator:">
<em class="property">class </em><tt class="descclassname">afidd::smv::</tt><tt class="descname">GammaDistribution<RandomNumberGenerator></tt><a class="headerlink" href="#afidd::smv::GammaDistribution:RandomNumberGenerator:" title="Permalink to this definition">¶</a></dt>
<dd><p>This uses the Boost::Math::gamma_distribution.
It has two parameters, shape and scale.</p>
</dd></dl>
<dl class="function">
<dt id="afidd::smv::GammaDistribution::GammaDistribution__double.double.double.double.double">
<tt class="descclassname">afidd::smv::GammaDistribution::</tt><tt class="descname">GammaDistribution</tt><big>(</big>double <em>alpha</em>, double <em>theta</em>, double <em>enabling_time</em>, double <em>shift</em><em>=0.0</em>, double <em>normal</em><em>=1.0</em><big>)</big><a class="headerlink" href="#afidd::smv::GammaDistribution::GammaDistribution__double.double.double.double.double" title="Permalink to this definition">¶</a></dt>
<dd><p>The constructor initializes the two parameters, <span class="math">\(\alpha\)</span> and <span class="math">\(\theta.\)</span> It also sets the enabling time and optional shift and normal.</p>
</dd></dl>
</div>
<div class="section" id="piecewise-linear-distribution">
<h2>Piecewise Linear Distribution<a class="headerlink" href="#piecewise-linear-distribution" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="afidd::smv::PiecewiseLinearDistribution:RandomNumberGenerator:">
<em class="property">class </em><tt class="descclassname">afidd::smv::</tt><tt class="descname">PiecewiseLinearDistribution<RandomNumberGenerator></tt><a class="headerlink" href="#afidd::smv::PiecewiseLinearDistribution:RandomNumberGenerator:" title="Permalink to this definition">¶</a></dt>
<dd><p>This distribution represents piecewise, linear, continuous distributions.
It is an expansion on the <cite>std::piecewise_linear_distribution</cite> from
the <cite>std::random</cite> header. The piecewise curve defines an un-normalized
probability density function, from which the cumulative distribution
function is calculated.</p>
</dd></dl>
<dl class="function">
<dt id="afidd::smv::PiecewiseLinearDistribution::PiecewiseLinearDistribution__std::vector:double:CR.std::vector:double:CR.double.double.double">
<tt class="descclassname">afidd::smv::PiecewiseLinearDistribution::</tt><tt class="descname">PiecewiseLinearDistribution</tt><big>(</big>const std::vector<double>& <em>b</em>, const std::vector<double>& <em>w</em>, double <em>enabling_time</em>, double <em>shift</em><em>=0.0</em>, double <em>normal</em><em>=1.0</em><big>)</big><a class="headerlink" href="#afidd::smv::PiecewiseLinearDistribution::PiecewiseLinearDistribution__std::vector:double:CR.std::vector:double:CR.double.double.double" title="Permalink to this definition">¶</a></dt>
<dd><p>The vector <cite>b</cite> specifies intercepts on the x-axis. The domain of the
probability distribution function is from the first to last value of
<cite>b</cite>. The weight vector, <cite>w,</cite> is the height of the unnormalized
function at each point <cite>b.</cite> The arrays <cite>b</cite> and <cite>w</cite> must have at
least two points and must be the same length.
The <cite>shift</cite> moves the whole distribution to the right. <cite>normal</cite>
is the probability that this distribution will fire at all.</p>
</dd></dl>
</div>
</div>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="dynamics.html" title="Dynamics Reference"
>next</a> |</li>
<li class="right" >
<a href="marking.html" title="Marking Reference"
>previous</a> |</li>
<li><a href="index.html">Semi-Markov 1.0 documentation</a> »</li>
<li><a href="reference.html" >Semi-Markov Library Reference</a> »</li>
</ul>
</div>
<div class="footer">
© Copyright 2014, Andrew Dolgert, David Schneider.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
</div>
</body>
</html>