Hi!
The scripts producing the images in the carrousel are
here:https://github.com/openturns/www/tree/master/_images/scripts
Warning! The scripts are not executed at each new release, so they may need a
little bit of effort to make them work with the last release. Here is an
updated version of the script you are looking for.
The two changes are:1) ot.Function->ot.SymbolicFunction2) no more output
description in the definition of a symbolic function
The figure will NOT be created into the current directory, but rather into the
upper level directory.
Cheers
Régis
from __future__ import print_function
from openturns.viewer import View
import openturns as ot
sampleSize = 4
dimension = 1
f = ot.SymbolicFunction(['x'], ['0.5*x^2 + sin(2.5*x)'])
# Database
xMin = -0.9
xMax = 1.9
X = ot.LHSExperiment(ot.Uniform(xMin, xMax), sampleSize, False,
False).generate()
Y = f(X)
# create algorithm
basis = ot.ConstantBasisFactory(dimension).build()
covarianceModel = ot.MaternModel([1.0], 1.5)
ot.Log.Show(ot.Log.INFO)
algo = ot.KrigingAlgorithm(X, Y, covarianceModel, basis)
algo.run()
# perform an evaluation
result = algo.getResult()
meta = result.getMetaModel()
graph_meta = meta.draw(xMin, xMax)
data = graph_meta.getDrawable(0).getData()
xGrid = data.getMarginal(0)
covGrid = result.getConditionalCovariance(xGrid)
a = ot.DistFunc.qNormal(0.975)
c = ot.Cloud([data[2]])
c.setPointStyle("square")
c.setColor("green")
c.setLegend("95% confidence bound")
dataLower = [[data[i, 0], data[i, 1] - a * covGrid[i, i]] for i in
range(len(data))]
dataUpper = [[data[i, 0], data[i, 1] + a * covGrid[i, i]] for i in
range(len(data))]
bounds = ot.PolygonArray([ot.Polygon([dataLower[i], dataLower[i+1],
dataUpper[i+1], dataUpper[i]], "green", "green") for i in
range(len(dataLower)-1)])
graph = ot.Graph()
graph.setLegendPosition("bottomright")
graph.setAxes(True)
graph.setGrid(True)
graph.add(c)
graph.add(bounds)
d = f.draw(xMin, xMax).getDrawable(0)
d.setLineStyle("dashed")
d.setColor("magenta")
d.setLineWidth(2)
graph.add(d)
graph.add(graph_meta)
cloud = ot.Cloud(X, Y)
cloud.setPointStyle("circle")
cloud.setColor("red")
graph.add(cloud)
graph.setTitle("Kriging meta-modeling")
graph.setXTitle(r"$x$")
graph.setYTitle(r"$f$")
graph.setLegends(["95% conf. bounds", "true function", "meta-model", "data"])
view = View(graph, (800, 600))
view.save("../plot_kriging.png")
view.close()
Le mercredi 24 avril 2019 à 15:26:37 UTC+2, BAUDIN Michael
<[email protected]> a écrit :
Hi !
I am currently working on kriging and try to reproduce the graphics which is
printed in the carrousel of openturns.org (see attachement). More precisely, I
would like to compute the 95% confidence bounds of the kriging predictions.
However, I could not find the script corresponding to the figure neither on
openturns.org nor in the doc (nor in the Slides of the User’s days, nor in the
Use Cases Guide). Is this Python script available ?
I also tried to produce the script by myself, and failed.... In attachment, I
put a Python script which tries to reproduce the figure. Notice however, that
the confidence bounds are extremely tight compared to what I expected. My guess
is that the issue is related to the estimate of the covariance model : in
OpenTURNS, the SquaredExponential is anisotropic while the figure might be
produced with an isotropic covariance. I also tried to prevent the optimization
algorithm from tuning the theta parameter with the setOptimizeParameters
method, but I wasn’t able to use correctly (the parameters still change,
however with a different value). What is the explanation for these tight bounds
?
Best regards,
Michaël
Michaël BAUDIN
Ingénieur - Chercheur
EDF – R&D
Département Management des Risques Industriels
6, quai Watier
78401 CHATOU
[email protected]
Tél. : 01 30 87 81 82
Fax : 01 30 87 82 13
Ce message et toutes les pièces jointes (ci-après le 'Message') sont établis à
l'intention exclusive des destinataires et les informations qui y figurent sont
strictement confidentielles. Toute utilisation de ce Message non conforme à sa
destination, toute diffusion ou toute publication totale ou partielle, est
interdite sauf autorisation expresse.
Si vous n'êtes pas le destinataire de ce Message, il vous est interdit de le
copier, de le faire suivre, de le divulguer ou d'en utiliser tout ou partie. Si
vous avez reçu ce Message par erreur, merci de le supprimer de votre système,
ainsi que toutes ses copies, et de n'en garder aucune trace sur quelque support
que ce soit. Nous vous remercions également d'en avertir immédiatement
l'expéditeur par retour du message.
Il est impossible de garantir que les communications par messagerie
électronique arrivent en temps utile, sont sécurisées ou dénuées de toute
erreur ou virus.
____________________________________________________
This message and any attachments (the 'Message') are intended solely for the
addressees. The information contained in this Message is confidential. Any use
of information contained in this Message not in accord with its purpose, any
dissemination or disclosure, either whole or partial, is prohibited except
formal approval.
If you are not the addressee, you may not copy, forward, disclose or use any
part of it. If you have received this message in error, please delete it and
all copies from your system and notify the sender immediately by return message.
E-mail communication cannot be guaranteed to be timely secure, error or
virus-free.
_______________________________________________
OpenTURNS users mailing list
[email protected]
http://openturns.org/mailman/listinfo/users
_______________________________________________
OpenTURNS users mailing list
[email protected]
http://openturns.org/mailman/listinfo/users