# We fix the parameter of the Cauchy model
amplitude = [5]
scale = [3]
model = ot.CauchyModel(scale, amplitude)
gp = ot.SpectralGaussianProcess(model, myTimeGrid)

# Get a time series or a sample of time series
# myTimeSeries = gp.getRealization()
mySample = gp.getSample(1000)

mySegmentNumber = 10
myOverlapSize = 0.3

# Build a spectral model factory
myFactory = ot.WelchFactory(ot.Hanning(), mySegmentNumber, myOverlapSize)

# Estimation on a TimeSeries or on a ProcessSample
# myEstimatedModel_TS = myFactory.build(myTimeSeries)
myEstimatedModel_PS = myFactory.buildAsUserDefinedSpectralModel(mySample)

# Change the filtering window
myFactory.setFilteringWindows(ot.Hamming())

# Get the FFT algorithm
myFFT = myFactory.getFFTAlgorithm()

# Get the frequencyGrid
frequencyGrid = myEstimatedModel_PS.getFrequencyGrid()

# With the model, we want to compare values
covmodel = ot.ExponentialModel(scale, amplitude)

# Create a stationary Normal process with that covariance model
process = ot.GaussianProcess(covmodel, tgrid)

# Create a time series and a sample of time series
tseries = process.getRealization()
sample = process.getSample(1000)

# %%
# Build a factory of stationary covariance function
covarianceFactory = ot.StationaryCovarianceModelFactory()

# Set the spectral factory algorithm
segmentNumber = 5
spectralFactory = ot.WelchFactory(ot.Hanning(), segmentNumber)
covarianceFactory.setSpectralModelFactory(spectralFactory)

# Check the current spectral factory
print(covarianceFactory.getSpectralModelFactory())

# %%
# Case 1 :  Estimation on a ProcessSample

# The spectral model factory computes the spectral density function
# without using the block and overlap arguments of the Welch factories
estimatedModel_PS = covarianceFactory.build(sample)

# Case 2 :  Estimation on a TimeSeries

# The spectral model factory compute the spectral density function using
예제 #3
0
# We fix the parameter of the Cauchy model
amplitude = [5.0]
scale = [3.0]
model = ot.CauchyModel(amplitude, scale)
process = ot.SpectralGaussianProcess(model, tgrid)

# Get a time series or a sample of time series
tseries = process.getRealization()
sample = process.getSample(1000)

# %%
# Build a spectral model factory
segmentNumber = 10
overlapSize = 0.3
factory = ot.WelchFactory(ot.Hann(), segmentNumber, overlapSize)

# %%
# Estimation on a TimeSeries or on a ProcessSample
estimatedModel_TS = factory.build(tseries)
estimatedModel_PS = factory.build(sample)

# %%
# Change the filtering window
factory.setFilteringWindows(ot.Hamming())

# %%
# Get the frequencyGrid
frequencyGrid = ot.SpectralGaussianProcess(estimatedModel_PS,
                                           tgrid).getFrequencyGrid()
예제 #4
0
# CASE 1 : we specify a (p,q) order

# Specify the order (p,q)
p = 4
q = 2

# Create the estimator
factory = ot.WhittleFactory(p, q)
print("Default spectral model factory = ", factory.getSpectralModelFactory())

# To set the spectral model factory
# For example, set WelchFactory as SpectralModelFactory
# with the Hann filtering window
# The Welch estimator splits the time series in four blocs without overlap
myFilteringWindow = ot.Hann()
mySpectralFactory = ot.WelchFactory(myFilteringWindow, 4, 0)
factory.setSpectralModelFactory(mySpectralFactory)
print("New spectral model factory = ", factory.getSpectralModelFactory())

# Estimate the ARMA model from a time series
# To get the quantified AICc, AIC and BIC criteria
arma42, criterion = factory.buildWithCriteria(tseries)
AICc, AIC, BIC = criterion[0:3]
print('AICc=', AICc, 'AIC=', AIC, 'BIC=', BIC)
arma42

# %%
# CASE 2 : we specify a range of (p,q) orders

# Range for p
pIndices = [1, 2, 4]