Sinusoidal dependance

Hello
I am studying a model with an angle as input parameter, angle in [0,360deg]
So I run a DOE and it appears obviously a sinusoidal dependance (view with scatter plots). And therefore direct PCE or kriging metamodels with this angle as input are not very good… Should I introduce an intermediate input parameter as cos(theta) or sin(theta) ? Should I do such a thing directly in Persalys GUI ?

Thanks in advance!
Best regards
Flore

Hi Flore! If I understand your problem correctly, I see 2 ways of tackling it. One is theoretically grounded, but requires you to code your own covariance kernel, and only works with Kriging. The other is easier and works with both any metamodel, but is essentially a hack.

Kriging: mathematically sound method

To do this properly with a Kriging algorithm, you essentially need to use a covariance kernel defined on the unit circle.

The problem is, no such kernel is currently implemented in OpenTURNS. However, you can build it yourself (in OpenTURNS, not Persalys unfortunately).

Following Padonou and Roustant (2016), we can for example compose a Wendland function with the geodesic distance on the unit sphere to produce such a kernel (see pages 7 and 8 in the article):

import openturns as ot
from math import pi
geodesic_distance = ot.SymbolicFunction('theta', 'acos(cos(theta))')
wendland_function = ot.SymbolicFunction('t', '(1 + 4t) * max(0, 1 - t)^4') # c = 1, tau = 4
rho = ot.ComposedFunction(wendland_function, geodesic_distance)
cov = ot.StationaryFunctionalCovarianceModel([360 / 2 / pi], [1.0], rho)

Note that you cannot compose any covariance kernel on the real line with the geodesic distance to get a proper kernel for the unit circle! It must have specific properties which are given in the article, but the Wendland function above has them.

Here is what the covariance function looks like:

cov.draw(0, 0, 0.0, 600.0, 1000)

image

As you can see, it it is periodic and its period length is 360.

Be careful however, if you use this kernel, you cannot allow the Kriging hyperparameter optimization algorithm to estimate the length scale of cov, otherwise the period length will change. Since the length scale is parameter #0 and the amplitude is parameter #1, you can disable length scale estimation with:

cov.setActiveParameter([1]) # only the amplitude will be estimated

Kriging and PCE : easy method

An easier, but mathematically ungrounded method, would be to replicate your dataset on several periods before training the Kriging / PCE algorithm.

For example, you could create a copy of your dataset with input values in the range [-360, 0], and another in the range [360, 720]. And then train the Kriging / PCE metamodel on the “augmented” dataset with input range [-360, 720], even if in the end you only use the metamodel on the [0, 360] range.

If you do this, you can of course use either OpenTURNS or Persalys.

Hello, thanks Joseph
I tried the second method, because it’s quicker
Unfortunately it does not work very well… Q2 values are always bad (but less bad than before with the DOE with interval [0,360])
Si I will try later the first method

Hi Flore,
Can you share a script to better illustrate your problem? Not sure it would help, but are you aware of the FourierSeriesFactory, which can b used with FunctionalChaosAlgorithm?

Cheers

Régis

I think I could share my data (as a CSV file)
I don’t know FourierSeriesFactory…

Good. I don’t know if you can attach them to the post, but you can directly send them to me!

Quick question: how did you compute the Q2 for the metamodel built with the “quick and dirty” method? Persalys provides 3 options: analytical, separate test set, K-fold.

Hello Joseph
Thanks for all

I build the data from -360deg to 720deg, put them in a CSV file, load it in Persalys v13.1, build metamodels using K-Fold method for Q2 evaluation. In my original data I had 1000 computation points

Merry Christmas to all of you !

Hi Flore,

Sorry for the delay.

I tried to build a PCE meta-model using the FourierSeries basis, but I cannot get something good based on the sample you sent to me. It looks like your problem is not so simple and more points are needed for a good PCE. You may have a better luck using other methods…

Cheers

Régis

Hi @Flore and sorry for the late reply, I have only just come back from my holiday.

Be careful with the way you compute Q2 with the “quick and dirty” method.

The only reasonable way to compute the Q2 is on data that belongs to the original interval [0,360]. Unfortunately you can’t do this using the native Persalys options, you need to do it manually.
IMO what you should do is :

  1. split your dataset beforehand between train and test set,
  2. replicate the training set only,
  3. compute the Q2 on the test set (e.g., with the OpenTURNS MetaModelValidation class).