From 8f6f7f4543bc8108097c0356a5829de7e62d6a2b Mon Sep 17 00:00:00 2001
From: rakhimov
Date: Wed, 21 Dec 2016 18:47:39 -0800
Subject: [PATCH 1/2] Add Piecewise-Linear Distribution specification
The specification describes
the distribution, its density and expected value.
Its initial grammar is added based on the histogram distribution.
---
mef/schema/random_deviate.rnc | 2 ++
mef/schema/stochastic_layer.rnc | 1 +
mef/stochastic_layer.rst | 34 +++++++++++++++++++++++++++++++++
3 files changed, 37 insertions(+)
diff --git a/mef/schema/random_deviate.rnc b/mef/schema/random_deviate.rnc
index e5e834a..365b548 100644
--- a/mef/schema/random_deviate.rnc
+++ b/mef/schema/random_deviate.rnc
@@ -11,4 +11,6 @@ beta-deviate = element beta-deviate { expression, expression }
histogram = element histogram { expression, bin+ }
+piecewise-linear = element piecewise-linear { bin+ }
+
bin = element bin { expression, expression }
diff --git a/mef/schema/stochastic_layer.rnc b/mef/schema/stochastic_layer.rnc
index 1b66137..da7dafa 100644
--- a/mef/schema/stochastic_layer.rnc
+++ b/mef/schema/stochastic_layer.rnc
@@ -18,5 +18,6 @@ random-deviate =
| gamma-deviate
| beta-deviate
| histogram
+ | piecewise-linear
test-event = test-initiating-event | test-functional-event
diff --git a/mef/stochastic_layer.rst b/mef/stochastic_layer.rst
index d142ea3..51be286 100644
--- a/mef/stochastic_layer.rst
+++ b/mef/stochastic_layer.rst
@@ -556,6 +556,8 @@ As for arithmetic operators and built-ins, this list can be extended on demand.
+-----------------------+------------+-------------------------------------------------------------------------------------------------------------+
| **histograms** | any | discrete distributions defined by means of a list of pairs |
+-----------------------+------------+-------------------------------------------------------------------------------------------------------------+
+ | **piecewise-linear** | >1 | piecewise-linear distributions defined by means of a list of pairs |
+ +-----------------------+------------+-------------------------------------------------------------------------------------------------------------+
Uniform Deviates
These primitives describe uniform distributions in a given range
@@ -713,6 +715,38 @@ Histograms
with the initial value
:math:`x_0 = 0, x_1 = 2m_1, \text{ and } x_i = x_{i-1} + 2(m_i - x_{i-1})`.
+Piecewise-Linear Distributions
+ Piecewise-linear distributions are lists of pairs :math:`(b_0, w_0), \ldots, (b_n, w_n)`,
+ where the :math:`b_i`'s are bounds of successive, contiguous intervals
+ such that :math:`b_i < b_{i+1}` for :math:`i = 0, \dots, n-1`,
+ and the :math:`w_i`'s are non-negative weights of corresponding interval bounds :math:`b_i`.
+
+ The distribution is defined by the following probability density function:
+
+ .. math::
+
+ f(x;b_0,\ldots,b_n, w_0,\ldots,w_n) = \frac{1}{S}
+ \left[\frac{w_k - w_{k-1}}{b_k - b_{k-1}}(x - b_{k-1}) + w_{k-1}\right]
+
+ Where :math:`k` is such that:
+
+ .. math::
+
+ b_{k-1} \leq x < b_k \quad \forall k \in \mathbb{Z} : 1 \leq k \leq n
+
+ :math:`S` is the total weight of the intervals for normalization:
+
+ .. math::
+
+ S = \sum_{i=1}^{n}\tfrac{1}{2}(w_i + w_{i-1})(b_i - b_{i-1})
+
+ The expected value of the piecewise-linear distribution is as follows.
+
+ .. math::
+
+ E(x) = \frac{1}{6S}
+ \sum_{i=1}^{n}(b_i - b_{i-1})[w_i(2b_i + b_{i-1}) + w_{i-1}(b_i + 2b_{i-1})]
+
XML Representation
------------------
From 567200f50bafd1e804e3a48bc2c7faef916b9e52 Mon Sep 17 00:00:00 2001
From: rakhimov
Date: Thu, 22 Dec 2016 04:58:06 -0800
Subject: [PATCH 2/2] Mention (continuous => piecewise-linear) function
Add a reference describing the significant points for extrapolations
on approximating continuous functions with piecewise linear functions.
---
mef/stochastic_layer.rst | 6 ++++++
spelling_wordlist.txt | 1 +
2 files changed, 7 insertions(+)
diff --git a/mef/stochastic_layer.rst b/mef/stochastic_layer.rst
index 51be286..0bae02c 100644
--- a/mef/stochastic_layer.rst
+++ b/mef/stochastic_layer.rst
@@ -720,6 +720,7 @@ Piecewise-Linear Distributions
where the :math:`b_i`'s are bounds of successive, contiguous intervals
such that :math:`b_i < b_{i+1}` for :math:`i = 0, \dots, n-1`,
and the :math:`w_i`'s are non-negative weights of corresponding interval bounds :math:`b_i`.
+ A piecewise-linear distribution can approximate a continuous distribution function [#HC94]_.
The distribution is defined by the following probability density function:
@@ -748,6 +749,11 @@ Piecewise-Linear Distributions
\sum_{i=1}^{n}(b_i - b_{i-1})[w_i(2b_i + b_{i-1}) + w_{i-1}(b_i + 2b_{i-1})]
+.. [#HC94] B. Hamann and J. L. Chen,
+ "Data point selection for piecewise linear curve approximation,"
+ Computer Aided Geometric Design, vol. 11, no. 3, pp. 289-301, 1994.
+
+
XML Representation
------------------
diff --git a/spelling_wordlist.txt b/spelling_wordlist.txt
index 26c9327..bf6234a 100644
--- a/spelling_wordlist.txt
+++ b/spelling_wordlist.txt
@@ -1,6 +1,7 @@
Ai
CCF
Fi
+Hamann
LAnguage
Napierian
PSA