# Applying PCE for time dependent ODE models

Hello guys,
I am new to UQLab.
I am trying to use PCE to build a metamodel for my time-dependent computational model that is built using Matlab ode45, and it has a few input parameters that take random variables. The output of my model is time series data for a specific combination of input parameters.
I know how to work with scalar models like the ishigami function but I am not sure how to implement the aforementioned model.
I would be grateful if you could help me by sharing a resource or providing a hint.

Hi @slodan

I usually consider each time instance of the model as a different model output. Then, if your aim is to perform a sensitivity analysis, you could consider each output’s sensitivity as a time instance.
For this, you could also see the work of Alexanderian et al. “Variance-based sensitivity analysis for time-dependent processes” to interpret the results.

I hope this helped.

Hello @giansteve

My aim is to perform time-frozen PCE analysis, and I tried to compute the metamodel independently for each time instance, by passing time instances as a parameter to my model. But since it is computationally demanding it took a lot of time. Is there any other simpler or more efficient method?

Hi @slodan

What do you mean by time-frozen PCE analysis?
You said you passed time instances as a parameter into your model. How did you statistically model the time parameter for the PCE computation? I think this is one of the main issues here, i.e., the modeling of the time as a random variable for the PCE computation. Time can not be a random variable. At least not from what I understand. It could be a random variable in your problem. You could paste your code here to explain your intent better.

By considering your problem from another perspective, you are trying to construct a PCE (a surrogate model) of your time-dependent model. Therefore, you aim at having a time-dependent PCE. The surrogate model only approximates your model’s map from the input to the output. In the case of time-dependent output, your mapping will vary in time. In other words, when you solve your ode45 with your input \boldsymbol{x}, you get a solution vector \boldsymbol{z} of dimension N_\mathrm{t} x N_\mathrm{out} and a time vector \boldsymbol{t} of dimension N_\mathrm{t} x 1 (say from 0 to 1 for a normalized time). The PCE approximates a set of N_\mathrm{out} hyper-surfaces of your domain, one for each time step. Therefore, you need a PCE per time instance.

There is also something else. I assume that the PDF of your input random variables does not change in time. If this is not the case, I propose you read “Time-dependent generalized polynomial chaos” by Gerritsma et al., 2010. It could be a good start.

I hope this is clear. Let me know your opinion about all this

Thank you @giansteve,
To make it clear, I am trying to construct a surrogate model using PCE. And I am passing time as a non-random variable to my model. As you have explained it above, the output of the ode45 based model is a time series output for a given combination of random variables. But, I used the time variable that is passed to my model to select/get a single 1\times1 output for the desired time instance. For example, if my model returns a 1\times N_t array of displacement values x(t), since I need a single displacement value at each time instance for instance x(t_o), I pass t_o to my model. My question here is if there are another ways of doing this modelling more efficiently instead of creating a a large (1\times N_t) metamodels (metamodels for each time instance).

I will check out the paper that you have suggested thank you!

Dear @slodan

I assume you are referring to the work of Chu V. Mai? I don’t remember all the details of his work, but I can give you some of my thoughts on it.
As you said, time-frozen PCE is computationally intensive. It also has other drawbacks, for example, the mapping \xi \to \mathcal{M}(\xi, t) (\xi is the input vector) usually becomes strongly nonlinear for late time steps. Chu improved this by using stochastic time warping, where all trajectories are transformed to a common new time scale, in which the mapping is usually simpler. The time transformation itself is also learned from the data (“Surrogate models for oscillatory systems using sparse polynomial
chaos expansions and stochastic time warping”, Mai et al., 2017).
However, I would suggest not limiting yourself to these static methods, but also taking a look at autoregressive approaches. There is already literature on time-dependent systems with uncertain properties, which is what you are trying to do, if I understand correctly:

• “Metamodeling nonlinear structural systems with parametric uncertainty under stochastic dynamic excitation”, Spiridonakos et al., 2015
• “Surrogate modeling for stochastic dynamical systems by combining NARX models and polynomial chaos expansions”, Mai et al., 2016

Unfortunately, UQLab does not yet implement autoregressive models.

Out of curiosity, how are the results you obtained with the time-frozen PCE?

Best regards
Styfen