Hi Phil,
First of all, thank you for using OpenTURNS. Here is my input concerning your
questions:
1. It is very easy to flip/translate (and even scale) an univariate
distribution in OpenTURNS using the arithmetic of random variables, see
flip_distribution.py.
2. There is currently no way to truncate multivariate distributions in
OpenTURNS, but a quick and dirty (ie mathematically correct but not optimized)
way to get it is given in truncated_nd_distribution.py
3. I have no idea on what is going on. I added the relevant guys to the
discussion, but keep in mind that Denis and Julien are on holidays and Sofiane
has a terrible workload, so you may have to wait a little bit for their input
For this kind of questions, it is better to use the users mailing list, see
http://openturns.org/mailman/listinfo/users to subscribe to the list.
Best regards,
Régis
De :Phil Fernandes [mailto:[email protected]]
Envoyé : mardi 25 juillet 2017 00:29
À : LEBRUN, Regis; [email protected]
Objet : OpenTurns inquiry
Hello Regis, Denis,
I am an engineer with Enbridge Pipelines and we have recently begun using
OpenTurns for reliability analysis of our infrastructure. So far I am finding
it to be an excellent and very comprehensive software library – thank you for
helping develop it.
I have run into a few of issues when using OpenTurns and was wondering if you
might be able to provide some help:
1. Is there a way of mirroring skewed distributions, for example flipping
a Weibull distribution so that instead of a lower limit it has an upper limit?
2. Is it possible to truncate a multivariate kernel density
distributions? We can truncate univariate parametric distributions using the
syntax
truncdist = ot.TruncatedDistribution(mydist, lower, upper)
but is there something analogous for multivariate KDEs where we can define
bounds for each dimension?
3. There is a conflict between the Python library PyMC3 and Theano and
OpenTurns. If Theano is imported first, OpenTurns fails to import with the
following error
Traceback (most recent call last):
File "<ipython-input-3-704e69d30dff>", line 1, in <module>
import openturns as ot
File "C:\Anaconda3\lib\site-packages\openturns\__init__.py", line 61, in
<module>
from .common import *
File "C:\Anaconda3\lib\site-packages\openturns\common.py", line 20, in
<module>
_common = swig_import_helper()
File "C:\Anaconda3\lib\site-packages\openturns\common.py", line 19, in
swig_import_helper
return importlib.import_module('_common')
File "C:\Anaconda3\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_common'
If I reverse the import order (i.e., OpenTurns first, then PyMC3 or Theano),
then PymC3/Theano fails to import with
Traceback (most recent call last):
File "<ipython-input-2-e9f7838173a6>", line 5, in <module>
import pymc3 as pm
File "C:\Anaconda3\lib\site-packages\pymc3\__init__.py", line 5, in <module>
from .distributions import *
File "C:\Anaconda3\lib\site-packages\pymc3\distributions\__init__.py", line
1, in <module>
from . import timeseries
File "C:\Anaconda3\lib\site-packages\pymc3\distributions\timeseries.py", line
1, in <module>
import theano.tensor as tt
File "C:\Anaconda3\lib\site-packages\theano\__init__.py", line 80, in <module>
from theano.scan_module import (scan, map, reduce, foldl, foldr, clone,
File "C:\Anaconda3\lib\site-packages\theano\scan_module\__init__.py", line
41, in <module>
from theano.scan_module import scan_opt
File "C:\Anaconda3\lib\site-packages\theano\scan_module\scan_opt.py", line
60, in <module>
from theano import tensor, scalar
File "C:\Anaconda3\lib\site-packages\theano\tensor\__init__.py", line 9, in
<module>
from theano.tensor.subtensor import *
File "C:\Anaconda3\lib\site-packages\theano\tensor\subtensor.py", line 26, in
<module>
import theano.gof.cutils # needed to import cutils_ext
File "C:\Anaconda3\lib\site-packages\theano\gof\cutils.py", line 320, in
<module>
compile_cutils()
File "C:\Anaconda3\lib\site-packages\theano\gof\cutils.py", line 285, in
compile_cutils
preargs=args)
File "C:\Anaconda3\lib\site-packages\theano\gof\cmodule.py", line 2325, in
compile_str
return dlimport(lib_filename)
File "C:\Anaconda3\lib\site-packages\theano\gof\cmodule.py", line 302, in
dlimport
rval = __import__(module_name, {}, {}, [module_name])
ImportError: DLL load failed: The specified procedure could not be found.
Your help would be very much appreciated.
Thank you.
Phil Fernandes P.Eng, MASc
Engineer, Reliability Assessment
—
ENBRIDGE PIPELINES INC.
TEL: 780-420-8210 | FAX: 780-420-5234
7045 Enbridge Centre, 10175 101 Street NW, Edmonton, AB, T5J 0H3
www.enbridge.com
Integrity. Safety. Respect.
The information in this e-mail is confidential. The contents may not be
disclosed or used by anyone other than the addressee. Access to this e-mail by
anyone else is unauthorised.
If you are not the intended recipient, please notify Airbus immediately and
delete this e-mail.
Airbus cannot accept any responsibility for the accuracy or completeness of
this e-mail as it has been sent over public networks. If you have any concerns
over the content of this message or its Accuracy or Integrity, please contact
Airbus immediately.
All outgoing e-mails from Airbus are checked using regularly updated virus
scanning software but you should take whatever measures you deem to be
appropriate to ensure that this message and any attachments are virus free. import openturns as ot
distribution = ot.Weibull(2.0, 1.5)
flipped_distribution = 3.0 - distribution
xMin = -5.0
xMax = 7.0
graph = distribution.drawPDF(xMin, xMax)
graph.add(flipped_distribution.drawPDF(xMin, xMax))
graph.setTitle("")
graph.setColors(["red", "blue"])
graph.setLegends(["initial", "flipped"])
ot.Show(graph)
import openturns as ot
class TruncatedNDDistribution(ot.PythonDistribution):
def __init__(self, distribution, bounds):
super(TruncatedNDDistribution, self).__init__(distribution.getDimension())
if distribution.getDimension() != bounds.getDimension():
raise ValueError('Distribution and bounds have incompatible dimension')
bounds = bounds.intersect(distribution.getRange())
self.distribution_ = distribution
self.bounds_ = bounds
self.lowerBound_ = bounds.getLowerBound()
self.upperBound_ = bounds.getUpperBound()
self.normalization_ = distribution.computeProbability(bounds)
if self.normalization_ == 0.0:
raise ValueError('The truncation bounds have a zero probability')
def getRange(self):
return self.bounds_
def computePDF(self, X):
if not self.bounds_.numericallyContains(X):
return False
return self.distribution_.computePDF(X) / self.normalization_
def computeCDF(self, X):
interval = self.bounds_.intersect(ot.Interval([-ot.SpecFunc.MaxScalar]*self.distribution_.getDimension(), X))
return self.distribution_.computeProbability(interval) / self.normalization_
def getRealization(self):
stop = False
while not stop:
X = self.distribution_.getRealization()
stop = self.bounds_.contains(X)
return X
dimension = 2
size = 70
sample = ot.Normal(dimension).getSample(size)
ks = ot.KernelSmoothing().build(sample)
truncatedKS = ot.Distribution(TruncatedNDDistribution(ks, ot.Interval([-2.0]*dimension, [2.0]*dimension)))
graph = truncatedKS.drawPDF([-2.5]*dimension, [2.5]*dimension, [256]*dimension)
graph.add(ot.Cloud(truncatedKS.getSample(200)))
graph.setColors(["blue", "red"])
ot.Show(graph)
_______________________________________________
OpenTURNS users mailing list
[email protected]
http://openturns.org/mailman/listinfo/users