[ot-users] Orthogonal basis of a polynomial chaos

regis lebrun regis_anne.lebrun_dutfoy at yahoo.fr
Wed Apr 19 16:04:25 CEST 2017


The main point is: if you rely on the objects upon which the algorithm is built, they are more strongly typed than the objects you retreive from the algorithm. And you are right, the only way to downcast the C++ objects in Python is to inspect their internal representation, either str(obj) or (more likely) repr(obj). So it is the solution I was working on before to be interrupted  by a colleague!

Here is the solution I propose (see attached script).

Cheers

Régis



________________________________
De : BAUDIN Michael <michael.baudin at edf.fr>
À : "regis_anne.lebrun_dutfoy at yahoo.fr" <regis_anne.lebrun_dutfoy at yahoo.fr>; "users at openturns.org" <users at openturns.org> 
Envoyé le : Mercredi 19 avril 2017 15h24
Objet : Re: [ot-users] Orthogonal basis of a polynomial chaos



That's true : not all distributions are normal distributions !

I would like to get the "type of" polynomial used for each variable. In the example I used (Ishigami function), this would allow to print the following table :

Variable    Distribution    Polynomial
X0        Uniform    Legendre
X1        Uniform    Legendre
X2        Uniform    Legendre

Hence, the information I am looking for could be :
* a string, e.g. "Legendre", 
* a class, e.g. "LegendreFactory".

Computing the string depending on the class would be a simple map (e.g. LegendreFactory > Legendre). However, if that map was already available in OT, that would make the process a little bit easier.

If I was able to get an access to the LegendreFactory used in the polynomial, it would be easy to get the information :

>>> from openturns import LegendreFactory
>>> polyfamily = LegendreFactory()
>>> polyfamily.getClassName()
'LegendreFactory'

With this information, the table would be :

Variable    Distribution    Polynomial
X0        Uniform    LegendreFactory
X1        Uniform    LegendreFactory
X2        Uniform    LegendreFactory

This table is already very informative for me : no need for a map in this case.

I answer to the other questions :

* The expression of these polynomials in the canonical basis in order to check that they match your expectation?  No : the expression itself does not interest me at all.
* And to get this information, you want to rely only on the algorithm? Yes, I would rather do this : this is because it makes  things simpler, as a post-processing of the chaos. However, that might be impossible : in this case, using intermediate objects in the script would do the trick.
* If yes, is it before or after it has computed the approximation? I would rather do it after the computation. But, since all the information is available before the computation of the coefficients, I guess that it would make sense to use the information available before.

I was thinking of a trick. The information is available inside the pretty-print : 

>>> poly0 = polyColl[0]
>>> poly0
class=OrthogonalUniVariatePolynomialFamily implementation=class=StandardDistributionPolynomialFactory hasSpecificFamily=true specificFamily=class=OrthogonalUniVariatePolynomialFamily implementation=class=LegendreFactory measure=class=Uniform name=Uniform dimension=1 a=-1 b=1

So I could use the string generated with str(poly0) ans parse this string... Ugly, isn'it ?

Regards,

Michaël

-----Message d'origine-----
De : regis_anne.lebrun_dutfoy at yahoo.fr [mailto:regis_anne.lebrun_dutfoy at yahoo.fr] 
Envoyé : mercredi 19 avril 2017 14:32
À : BAUDIN Michael; users at openturns.org
Objet : Re: [ot-users] Orthogonal basis of a polynomial chaos

Hi Michael,


First of all, thanks for using OpenTURNS ;-)! And a remark: in the case of uniform distributions, you are more likely to get Legendre polynomials than Hermite polynomials :-)

Something in your request is not clear for me. What kind of confirmation do you want to get from openTURNS? A string containing the name of the univariate families of polynomials which have been used? The expression of these polynomials in the canonical basis in order to check that they match your expectation? And to get this information, you want to rely only on the algorithm? If yes, is it before or after it has computed the approximation?

Remember that the algorithm can work with ANY multivariate bases, not only polynomial ones, not even tensorized one, so if you rely only on the algorithm you will have to work a little bit to get the information you are looking for (and I will help you if you answer the few questions above).

In your script, you name your MonteCarloeExperiment as 'sample', which is misleading as it is NOT a sample, but rather a way to generate one. It is a particular case of WeightedExperiment, ie an algorithm able to produce samples.

Cheers

Régis


________________________________
De : BAUDIN Michael <michael.baudin at edf.fr> À : "users at openturns.org" <users at openturns.org> Envoyé le : Mercredi 19 avril 2017 13h20 Objet : Re: [ot-users] Orthogonal basis of a polynomial chaos



Hi again,
Here is a script in attachment to experiment with the objects.
Regards,
Michaël

De :BAUDIN Michael 
Envoyé : mercredi 19 avril 2017 11:50
À : 'users at openturns.org'
Objet : Orthogonal basis of a polynomial chaos

Hi,

After a (functionnal) polynomial chaos has been run, I am searching a way to explore what basis was used. For example, if a Uniform distribution was used, I would like to confirm that a Hermite polynomial was used. Of course, this cannot always been done, especially if one of the input distributions was « non-standard ». 

However, even in the classical case, I was not able to find out what method of the polynomialChaosAlgorithm could be used to retrieve the information. For example :

[…]
# Create Polynomial Chaos
polynomialChaosAlgorithm = FunctionalChaosAlgorithm(myFunction, \
    inputDistribution, fixedStrategy, evalStrategy)
# Compute expansion coefficients
polynomialChaosAlgorithm.run()

# Explore the result
myAdapStrat = polynomialChaosAlgorithm.getAdaptiveStrategy() # a AdaptiveStrategy
mybasis = myAdapStrat.getBasis() # a OrthogonalBasis
# and after … ?

Afterwhile, I thought that this was not possible, because the basis was an hidden internal object. This is why I tried a second solution : directly explore the polynomial collection used to create the collection of univariate polynomials :

# Create a coolection of standard univariate polynomials
polyColl = PolynomialFamilyCollection(dim)
for i in range(dim):
    marginali=inputDistribution.getMarginal(i)
    polyColl[i] = StandardDistributionPolynomialFactory(marginali)

# Explore the first polynomial
poly0 = polyColl[0]
# and after … ?

But I was not able to find a way to the Hermite polynomial neither.

Has anyone an idea ?

Regards,

Michaël

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
users at openturns.org
http://openturns.org/mailman/listinfo/users




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
users at openturns.org
http://openturns.org/mailman/listinfo/users
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Ishigami-PC-regression_RLN.py
Type: text/x-python
Size: 3007 bytes
Desc: not available
URL: <http://openturns.org/pipermail/users/attachments/20170419/1cb10057/attachment.py>


More information about the users mailing list