soerp3 0.9.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- soerp3-0.9.7/.gitignore +207 -0
- soerp3-0.9.7/.python-version +1 -0
- soerp3-0.9.7/LICENSE +30 -0
- soerp3-0.9.7/PKG-INFO +336 -0
- soerp3-0.9.7/README.rst +290 -0
- soerp3-0.9.7/pyproject.toml +167 -0
- soerp3-0.9.7/soerp3/__init__.py +1283 -0
- soerp3-0.9.7/soerp3/method_of_moments.py +1024 -0
- soerp3-0.9.7/soerp3/umath/__init__.py +10 -0
- soerp3-0.9.7/soerp3/umath/umath.py +343 -0
- soerp3-0.9.7/soerp_examples.py +275 -0
- soerp3-0.9.7/uv.lock +1765 -0
soerp3-0.9.7/.gitignore
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
#poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
#pdm.lock
|
|
116
|
+
#pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
#pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# SageMath parsed files
|
|
135
|
+
*.sage.py
|
|
136
|
+
|
|
137
|
+
# Environments
|
|
138
|
+
.env
|
|
139
|
+
.envrc
|
|
140
|
+
.venv
|
|
141
|
+
env/
|
|
142
|
+
venv/
|
|
143
|
+
ENV/
|
|
144
|
+
env.bak/
|
|
145
|
+
venv.bak/
|
|
146
|
+
|
|
147
|
+
# Spyder project settings
|
|
148
|
+
.spyderproject
|
|
149
|
+
.spyproject
|
|
150
|
+
|
|
151
|
+
# Rope project settings
|
|
152
|
+
.ropeproject
|
|
153
|
+
|
|
154
|
+
# mkdocs documentation
|
|
155
|
+
/site
|
|
156
|
+
|
|
157
|
+
# mypy
|
|
158
|
+
.mypy_cache/
|
|
159
|
+
.dmypy.json
|
|
160
|
+
dmypy.json
|
|
161
|
+
|
|
162
|
+
# Pyre type checker
|
|
163
|
+
.pyre/
|
|
164
|
+
|
|
165
|
+
# pytype static type analyzer
|
|
166
|
+
.pytype/
|
|
167
|
+
|
|
168
|
+
# Cython debug symbols
|
|
169
|
+
cython_debug/
|
|
170
|
+
|
|
171
|
+
# PyCharm
|
|
172
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
173
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
174
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
175
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
176
|
+
#.idea/
|
|
177
|
+
|
|
178
|
+
# Abstra
|
|
179
|
+
# Abstra is an AI-powered process automation framework.
|
|
180
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
181
|
+
# Learn more at https://abstra.io/docs
|
|
182
|
+
.abstra/
|
|
183
|
+
|
|
184
|
+
# Visual Studio Code
|
|
185
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
186
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
188
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
189
|
+
# .vscode/
|
|
190
|
+
|
|
191
|
+
# Ruff stuff:
|
|
192
|
+
.ruff_cache/
|
|
193
|
+
|
|
194
|
+
# PyPI configuration file
|
|
195
|
+
.pypirc
|
|
196
|
+
|
|
197
|
+
# Cursor
|
|
198
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
|
199
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
200
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
201
|
+
.cursorignore
|
|
202
|
+
.cursorindexingignore
|
|
203
|
+
|
|
204
|
+
# Marimo
|
|
205
|
+
marimo/_static/
|
|
206
|
+
marimo/_lsp/
|
|
207
|
+
__marimo__/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.13
|
soerp3-0.9.7/LICENSE
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2010 - 2018, Abraham Lee
|
|
4
|
+
Copyright (c) 2026, eggzec
|
|
5
|
+
All rights reserved.
|
|
6
|
+
|
|
7
|
+
Redistribution and use in source and binary forms, with or without
|
|
8
|
+
modification, are permitted provided that the following conditions are met:
|
|
9
|
+
|
|
10
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
11
|
+
list of conditions and the following disclaimer.
|
|
12
|
+
|
|
13
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
14
|
+
this list of conditions and the following disclaimer in the documentation
|
|
15
|
+
and/or other materials provided with the distribution.
|
|
16
|
+
|
|
17
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
18
|
+
contributors may be used to endorse or promote products derived from
|
|
19
|
+
this software without specific prior written permission.
|
|
20
|
+
|
|
21
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
22
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
23
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
24
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
25
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
26
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
27
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
28
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
29
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
30
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
soerp3-0.9.7/PKG-INFO
ADDED
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: soerp3
|
|
3
|
+
Version: 0.9.7
|
|
4
|
+
Summary: Second Order Error Propagation for Python
|
|
5
|
+
Project-URL: homepage, https://eggzec.github.io/soerp3/
|
|
6
|
+
Project-URL: documentation, https://eggzec.github.io/soerp3/
|
|
7
|
+
Project-URL: source, https://github.com/eggzec/soerp3
|
|
8
|
+
Project-URL: releasenotes, https://github.com/eggzec/soerp3/releases/latest
|
|
9
|
+
Project-URL: issues, https://github.com/eggzec/soerp3/issues
|
|
10
|
+
Author-email: Abraham Lee <tisimst@gmail.com>
|
|
11
|
+
Maintainer-email: Saud Zahir <m.saud.zahir@gmail.com>, M Laraib Ali <laraibg786@outlook.com>
|
|
12
|
+
License-Expression: BSD-3-Clause
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Keywords: derivative,distribution,error propagation,method of moments,second order,statistics,uncertainties,uncertainty analysis
|
|
15
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: Intended Audience :: Education
|
|
18
|
+
Classifier: Intended Audience :: Science/Research
|
|
19
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
20
|
+
Classifier: Operating System :: MacOS
|
|
21
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
22
|
+
Classifier: Operating System :: OS Independent
|
|
23
|
+
Classifier: Operating System :: POSIX
|
|
24
|
+
Classifier: Operating System :: Unix
|
|
25
|
+
Classifier: Programming Language :: Python
|
|
26
|
+
Classifier: Programming Language :: Python :: 3
|
|
27
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
28
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
29
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
30
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
31
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
32
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
33
|
+
Classifier: Topic :: Education
|
|
34
|
+
Classifier: Topic :: Scientific/Engineering
|
|
35
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
36
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
37
|
+
Classifier: Topic :: Software Development
|
|
38
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
39
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
40
|
+
Classifier: Topic :: Utilities
|
|
41
|
+
Requires-Python: >=3.10
|
|
42
|
+
Requires-Dist: matplotlib
|
|
43
|
+
Requires-Dist: numpy
|
|
44
|
+
Requires-Dist: scipy
|
|
45
|
+
Description-Content-Type: text/x-rst
|
|
46
|
+
|
|
47
|
+
===============================
|
|
48
|
+
``soerp`` Package Documentation
|
|
49
|
+
===============================
|
|
50
|
+
|
|
51
|
+
Overview
|
|
52
|
+
========
|
|
53
|
+
|
|
54
|
+
``soerp`` is the Python implementation of the original Fortran code `SOERP`
|
|
55
|
+
by N. D. Cox to apply a second-order analysis to `error propagation`_ (or
|
|
56
|
+
uncertainty analysis). The ``soerp`` package allows you to **easily** and
|
|
57
|
+
**transparently** track the effects of uncertainty through mathematical
|
|
58
|
+
calculations. Advanced mathematical functions, similar to those in the standard
|
|
59
|
+
math_ module can also be evaluated directly.
|
|
60
|
+
|
|
61
|
+
In order to correctly use ``soerp``, the **first eight statistical moments**
|
|
62
|
+
of the underlying distribution are required. These are the *mean*, *variance*,
|
|
63
|
+
and then the *standardized third through eighth moments*. These can be input
|
|
64
|
+
manually in the form of an array, but they can also be **conveniently
|
|
65
|
+
generated** using either the **nice constructors** or directly by using the
|
|
66
|
+
distributions from the ``scipy.stats`` sub-module. See the examples below for
|
|
67
|
+
usage examples of both input methods. The result of all calculations generates a
|
|
68
|
+
*mean*, *variance*, and *standardized skewness and kurtosis* coefficients.
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
Required Packages
|
|
72
|
+
=================
|
|
73
|
+
|
|
74
|
+
- ad_ : For first- and second-order automatic differentiation (install this first).
|
|
75
|
+
|
|
76
|
+
- NumPy_ : Numeric Python
|
|
77
|
+
|
|
78
|
+
- SciPy_ : Scientific Python (the nice distribution constructors require this)
|
|
79
|
+
|
|
80
|
+
- Matplotlib_ : Python plotting library
|
|
81
|
+
|
|
82
|
+
Basic examples
|
|
83
|
+
==============
|
|
84
|
+
|
|
85
|
+
Let's begin by importing all the available constructors::
|
|
86
|
+
|
|
87
|
+
>>> from soerp import * # uv, N, U, Exp, etc.
|
|
88
|
+
|
|
89
|
+
Now, we can see that there are several equivalent ways to specify a statistical distribution, say a Normal distribution with a mean value of 10 and a standard deviation of 1:
|
|
90
|
+
|
|
91
|
+
- Manually input the first 8 moments (mean, variance, and 3rd-8th standardized central moments)::
|
|
92
|
+
|
|
93
|
+
>>> x = uv([10, 1, 0, 3, 0, 15, 0, 105])
|
|
94
|
+
|
|
95
|
+
- Use the ``rv`` kwarg to input a distribution from the ``scipy.stats`` module::
|
|
96
|
+
|
|
97
|
+
>>> x = uv(rv=ss.norm(loc=10, scale=1))
|
|
98
|
+
|
|
99
|
+
- Use a built-in convenience constructor (typically the easiest if you can)::
|
|
100
|
+
|
|
101
|
+
>>> x = N(10, 1)
|
|
102
|
+
|
|
103
|
+
A Simple Example
|
|
104
|
+
----------------
|
|
105
|
+
|
|
106
|
+
Now let's walk through an example of a three-part assembly stack-up::
|
|
107
|
+
|
|
108
|
+
>>> x1 = N(24, 1) # normally distributed
|
|
109
|
+
>>> x2 = N(37, 4) # normally distributed
|
|
110
|
+
>>> x3 = Exp(2) # exponentially distributed
|
|
111
|
+
>>> Z = (x1*x2**2)/(15*(1.5 + x3))
|
|
112
|
+
|
|
113
|
+
We can now see the results of the calculations in two ways:
|
|
114
|
+
|
|
115
|
+
#. The usual ``print`` statement (or simply the object if in a terminal)::
|
|
116
|
+
|
|
117
|
+
>>> Z # "print" is optional at the command-line
|
|
118
|
+
uv(1176.45, 99699.6822917, 0.708013052944, 6.16324345127)
|
|
119
|
+
|
|
120
|
+
#. The ``describe`` class method that explains briefly what the values are::
|
|
121
|
+
|
|
122
|
+
>>> Z.describe()
|
|
123
|
+
SOERP Uncertain Value:
|
|
124
|
+
> Mean................... 1176.45
|
|
125
|
+
> Variance............... 99699.6822917
|
|
126
|
+
> Skewness Coefficient... 0.708013052944
|
|
127
|
+
> Kurtosis Coefficient... 6.16324345127
|
|
128
|
+
|
|
129
|
+
Distribution Moments
|
|
130
|
+
--------------------
|
|
131
|
+
|
|
132
|
+
The eight moments of any input variable (and four of any output variable) can be accessed using the ``moments`` class method, as in::
|
|
133
|
+
|
|
134
|
+
>>> x1.moments()
|
|
135
|
+
[24.0, 1.0, 0.0, 3.0000000000000053, 0.0, 15.000000000000004, 0.0, 105.0]
|
|
136
|
+
>>> Z.moments()
|
|
137
|
+
[1176.45, 99699.6822917, 0.708013052944, 6.16324345127]
|
|
138
|
+
|
|
139
|
+
Correlations
|
|
140
|
+
------------
|
|
141
|
+
|
|
142
|
+
Statistical correlations are correctly handled, even after calculations have taken place::
|
|
143
|
+
|
|
144
|
+
>>> x1 - x1
|
|
145
|
+
0.0
|
|
146
|
+
>>> square = x1**2
|
|
147
|
+
>>> square - x1*x1
|
|
148
|
+
0.0
|
|
149
|
+
|
|
150
|
+
Derivatives
|
|
151
|
+
-----------
|
|
152
|
+
|
|
153
|
+
Derivatives with respect to original variables are calculated via the ad_ package and are accessed using the **intuitive class methods**::
|
|
154
|
+
|
|
155
|
+
>>> Z.d(x1) # dZ/dx1
|
|
156
|
+
45.63333333333333
|
|
157
|
+
|
|
158
|
+
>>> Z.d2(x2) # d^2Z/dx2^2
|
|
159
|
+
1.6
|
|
160
|
+
|
|
161
|
+
>>> Z.d2c(x1, x3) # d^2Z/dx1dx3 (order doesn't matter)
|
|
162
|
+
-22.816666666666666
|
|
163
|
+
|
|
164
|
+
When we need multiple derivatives at a time, we can use the ``gradient`` and ``hessian`` class methods::
|
|
165
|
+
|
|
166
|
+
>>> Z.gradient([x1, x2, x3])
|
|
167
|
+
[45.63333333333333, 59.199999999999996, -547.6]
|
|
168
|
+
|
|
169
|
+
>>> Z.hessian([x1, x2, x3])
|
|
170
|
+
[[0.0, 2.466666666666667, -22.816666666666666], [2.466666666666667, 1.6, -29.6], [-22.816666666666666, -29.6, 547.6]]
|
|
171
|
+
|
|
172
|
+
Error Components/Variance Contributions
|
|
173
|
+
---------------------------------------
|
|
174
|
+
|
|
175
|
+
Another useful feature is available through the ``error_components`` class method that has various ways of representing the first- and second-order variance components::
|
|
176
|
+
|
|
177
|
+
>>> Z.error_components(pprint=True)
|
|
178
|
+
COMPOSITE VARIABLE ERROR COMPONENTS
|
|
179
|
+
uv(37.0, 16.0, 0.0, 3.0) = 58202.9155556 or 58.378236%
|
|
180
|
+
uv(24.0, 1.0, 0.0, 3.0) = 2196.15170139 or 2.202767%
|
|
181
|
+
uv(0.5, 0.25, 2.0, 9.0) = -35665.8249653 or 35.773258%
|
|
182
|
+
|
|
183
|
+
Advanced Example
|
|
184
|
+
----------------
|
|
185
|
+
|
|
186
|
+
Here's a *slightly* more advanced example, estimating the statistical properties of volumetric gas flow through an orifice meter::
|
|
187
|
+
|
|
188
|
+
>>> from soerp.umath import * # sin, exp, sqrt, etc.
|
|
189
|
+
>>> H = N(64, 0.5)
|
|
190
|
+
>>> M = N(16, 0.1)
|
|
191
|
+
>>> P = N(361, 2)
|
|
192
|
+
>>> t = N(165, 0.5)
|
|
193
|
+
>>> C = 38.4
|
|
194
|
+
>>> Q = C*umath.sqrt((520*H*P)/(M*(t + 460)))
|
|
195
|
+
>>> Q.describe()
|
|
196
|
+
SOERP Uncertain Value:
|
|
197
|
+
> Mean................... 1330.99973939
|
|
198
|
+
> Variance............... 58.210762839
|
|
199
|
+
> Skewness Coefficient... 0.0109422068056
|
|
200
|
+
> Kurtosis Coefficient... 3.00032693502
|
|
201
|
+
|
|
202
|
+
This seems to indicate that even though there are products, divisions, and the usage of ``sqrt``, the result resembles a normal distribution (i.e., Q ~ N(1331, 7.63), where the standard deviation = sqrt(58.2) = 7.63).
|
|
203
|
+
|
|
204
|
+
Main Features
|
|
205
|
+
=============
|
|
206
|
+
|
|
207
|
+
1. **Transparent calculations** with derivatives automatically calculated.
|
|
208
|
+
**No or little modification** to existing code required.
|
|
209
|
+
|
|
210
|
+
2. Basic `NumPy` support without modification. Vectorized calculations built-in
|
|
211
|
+
to the ``ad`` package.
|
|
212
|
+
|
|
213
|
+
3. Nearly all standard `math`_ module functions supported through the
|
|
214
|
+
``soerp.umath`` sub-module. If you think a function is in there, it probably
|
|
215
|
+
is.
|
|
216
|
+
|
|
217
|
+
4. Nearly all derivatives calculated analytically using ``ad`` functionality.
|
|
218
|
+
|
|
219
|
+
5. **Easy continuous distribution constructors**:
|
|
220
|
+
|
|
221
|
+
- ``N(mu, sigma)`` : `Normal distribution`_
|
|
222
|
+
|
|
223
|
+
- ``U(a, b)`` : `Uniform distribution`_
|
|
224
|
+
|
|
225
|
+
- ``Exp(lamda, [mu])`` : `Exponential distribution`_
|
|
226
|
+
|
|
227
|
+
- ``Gamma(k, theta)`` : `Gamma distribution`_
|
|
228
|
+
|
|
229
|
+
- ``Beta(alpha, beta, [a, b])`` : `Beta distribution`_
|
|
230
|
+
|
|
231
|
+
- ``LogN(mu, sigma)`` : `Log-normal distribution`_
|
|
232
|
+
|
|
233
|
+
- ``Chi2(k)`` : `Chi-squared distribution`_
|
|
234
|
+
|
|
235
|
+
- ``F(d1, d2)`` : `F-distribution`_
|
|
236
|
+
|
|
237
|
+
- ``Tri(a, b, c)`` : `Triangular distribution`_
|
|
238
|
+
|
|
239
|
+
- ``T(v)`` : `T-distribution`_
|
|
240
|
+
|
|
241
|
+
- ``Weib(lamda, k)`` : `Weibull distribution`_
|
|
242
|
+
|
|
243
|
+
The location, scale, and shape parameters follow the notation in the
|
|
244
|
+
respective Wikipedia articles. *Discrete distributions are not recommended
|
|
245
|
+
for use at this time. If you need discrete distributions, try the* mcerp_
|
|
246
|
+
*python package instead.*
|
|
247
|
+
|
|
248
|
+
Installation
|
|
249
|
+
============
|
|
250
|
+
|
|
251
|
+
**Make sure you install the** `ad`_ **package first!** (If you use options
|
|
252
|
+
3 or 4 below, this should be done automatically.)
|
|
253
|
+
|
|
254
|
+
You have several easy, convenient options to install the ``soerp`` package
|
|
255
|
+
(administrative privileges may be required)
|
|
256
|
+
|
|
257
|
+
1. Download the package files below, unzip to any directory, and run::
|
|
258
|
+
|
|
259
|
+
$ [sudo] python setup.py install
|
|
260
|
+
|
|
261
|
+
2. Simply copy the unzipped ``soerp-XYZ`` directory to any other location that
|
|
262
|
+
python can find it and rename it ``soerp``.
|
|
263
|
+
|
|
264
|
+
3. If ``setuptools`` is installed, run::
|
|
265
|
+
|
|
266
|
+
$ [sudo] easy_install [--upgrade] soerp
|
|
267
|
+
|
|
268
|
+
4. If ``pip`` is installed, run::
|
|
269
|
+
|
|
270
|
+
$ [sudo] pip install [--upgrade] soerp
|
|
271
|
+
|
|
272
|
+
Uninstallation
|
|
273
|
+
==============
|
|
274
|
+
|
|
275
|
+
To remove the package, there are really two good ways to do this:
|
|
276
|
+
|
|
277
|
+
1. Go to the folder ``site-packages`` or ``dist-packages`` and simply delete
|
|
278
|
+
the folder ``soerp`` and ``soerp-XYZ-egg-info``.
|
|
279
|
+
|
|
280
|
+
2. If ``pip`` is installed, run::
|
|
281
|
+
|
|
282
|
+
$ [sudo] pip uninstall soerp
|
|
283
|
+
|
|
284
|
+
See Also
|
|
285
|
+
========
|
|
286
|
+
|
|
287
|
+
- uncertainties_ : First-order error propagation
|
|
288
|
+
|
|
289
|
+
- mcerp_ : Real-time latin-hypercube sampling-based Monte Carlo error
|
|
290
|
+
propagation
|
|
291
|
+
|
|
292
|
+
Contact
|
|
293
|
+
=======
|
|
294
|
+
|
|
295
|
+
Please send **feature requests, bug reports, or feedback** to
|
|
296
|
+
`Abraham Lee`_.
|
|
297
|
+
|
|
298
|
+
Acknowledgements
|
|
299
|
+
================
|
|
300
|
+
|
|
301
|
+
The author wishes to thank `Eric O. LEBIGOT`_ who first developed the
|
|
302
|
+
`uncertainties`_ python package (for first-order error propagation),
|
|
303
|
+
from which many inspiring ideas (like maintaining object correlations, etc.)
|
|
304
|
+
are re-used and/or have been slightly evolved. *If you don't need second
|
|
305
|
+
order functionality, his package is an excellent alternative since it is
|
|
306
|
+
optimized for first-order uncertainty analysis.*
|
|
307
|
+
|
|
308
|
+
References
|
|
309
|
+
==========
|
|
310
|
+
|
|
311
|
+
- N.D. Cox, 1979, *Tolerance Analysis by Computer*, Journal of Quality Technology, Vol. 11, No. 2, pp. 80-87
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
.. _error propagation: http://en.wikipedia.org/wiki/Propagation_of_uncertainty
|
|
316
|
+
.. _math: http://docs.python.org/library/math.html
|
|
317
|
+
.. _ad: http://pypi.python.org/pypi/ad
|
|
318
|
+
.. _mcerp: http://pypi.python.org/pypi/mcerp
|
|
319
|
+
.. _NumPy: http://www.numpy.org/
|
|
320
|
+
.. _SciPy: http://scipy.org
|
|
321
|
+
.. _Matplotlib: http://matplotlib.org/
|
|
322
|
+
.. _uncertainties: http://pypi.python.org/pypi/uncertainties
|
|
323
|
+
.. _Abraham Lee: mailto: tisimst@gmail.com
|
|
324
|
+
.. _Eric O. LEBIGOT: http://www.linkedin.com/pub/eric-lebigot/22/293/277
|
|
325
|
+
.. _PEP8: http://www.python.org/dev/peps/pep-0008
|
|
326
|
+
.. _Normal distribution: http://en.wikipedia.org/wiki/Normal_distribution
|
|
327
|
+
.. _Uniform distribution: http://en.wikipedia.org/wiki/Uniform_distribution_(continuous)
|
|
328
|
+
.. _Exponential distribution: http://en.wikipedia.org/wiki/Exponential_distribution
|
|
329
|
+
.. _Gamma distribution: http://en.wikipedia.org/wiki/Gamma_distribution
|
|
330
|
+
.. _Beta distribution: http://en.wikipedia.org/wiki/Beta_distribution
|
|
331
|
+
.. _Log-normal distribution: http://en.wikipedia.org/wiki/Log-normal_distribution
|
|
332
|
+
.. _Chi-squared distribution: http://en.wikipedia.org/wiki/Chi-squared_distribution
|
|
333
|
+
.. _F-distribution: http://en.wikipedia.org/wiki/F-distribution
|
|
334
|
+
.. _Triangular distribution: http://en.wikipedia.org/wiki/Triangular_distribution
|
|
335
|
+
.. _T-distribution: http://en.wikipedia.org/wiki/Student's_t-distribution
|
|
336
|
+
.. _Weibull distribution: http://en.wikipedia.org/wiki/Weibull_distribution
|