hello,
I’ve tried using the ot.StationaryCovarianceModelFactory class in order to estimate a covariance matrix over a given time series. i’ve been experiencing some problems afterwards bc the obtained matrix is not necessarily a positive definite matrix. It seems that the parameter blockNumber in the Welshfactory class holds a great importance in that matter (the problem is solved if blockNumber = 10 in the following example).
here is a hopefully reproducible piece of code illustrating the matter :
‘’’
import numpy as np
import openturns as ot
np.random.seed(0)
myValues = [[i+np.random.uniform(5)] for i in range(size)]
myMesh = ot.RegularGrid(0, 10, size)
myField = ot.Field(myMesh, myValues)
covarianceFactory = ot.StationaryCovarianceModelFactory()
segmentNumber = 6
spectralFactory = ot.WelchFactory(ot.Hann(), segmentNumber)
covarianceFactory.setSpectralModelFactory(spectralFactory)
estimatedModel = covarianceFactory.build(myField)
def f(X):
s, t = X
return [(estimatedModel(s - t).computeTrace())]
errObs = ot.CovarianceMatrix(size)
for k in range(size):
s = myMesh.getValue(k)
for l in range(size):
t = myMesh.getValue(l)
errObs[k, l] = f([t, s])[0]
errObs.isPositiveDefinite()
‘’’
any advice on how to chose a reasonable blockNumber parameter would be greatly appreciated !
regards,
sanaa