Measures¶
Measures and other analysis functions useful for RC
Functions:
|
Synonym for the divergence_time fct. |
|
Calculates correlation dimension using the algorithm by Grassberger and Procaccia. |
|
Estimates parameters r_min and r_max for calculation of correlation dimension using the algorithm by Grassberger and Procaccia and uses them to calculate it. |
|
Calculates how long it takes for measurement and prediction to diverge |
|
Calculates the root mean squared error between two time series |
|
Calculates the NRMSE over time, |
- rescomp.measures.demerge_time(pred_time_series, meas_time_series, epsilon)¶
Synonym for the divergence_time fct.
- rescomp.measures.dimension(time_series, r_min=1.5, r_max=5.0, nr_steps=2, plot=False)¶
Calculates correlation dimension using the algorithm by Grassberger and Procaccia.
First we calculate a sum over all points within a given radius, then average over all basis points and vary the radius (grassberger, procaccia).
parameters depend on timesteps and the system itself!
- Parameters
time_series (np.ndarray) – time series to calculate dimension of, shape (T, d)
r_min (float) – minimum radius
r_max (float) – maximum radius
nr_steps (int) – number of steps in radius, if r_min and r_max are chosen properly, then 2 is enough.
plot (boolean) – flag for plotting loglog plot
- Returns: dimension: slope of the log.log plot assumes:
N_r(radius) ~ radius**dimension
- rescomp.measures.dimension_parameters(time_series, nr_steps=100, literature_value=None, plot=False, r_minmin=None, r_maxmax=None, shortness_weight=0.5, literature_weight=1.0)¶
Estimates parameters r_min and r_max for calculation of correlation dimension using the algorithm by Grassberger and Procaccia and uses them to calculate it.
This experimental function performs a simple grid search on r_min and r_max in the intervall given by r_minmin, r_maxmax and nr_steps. The performance of the parameters is measured by a combination of NRMSE, a penalty for small intervalls relative to given r_minmin and r_maxmax and a quadratic penalty for the difference from the literature value if given.
For calculating the dimension of a high number of similar time_series in a row it is advisable to use this function only once to get the parameters and then use the function dimension with them in the subsequent computations.
Might fail for short time_series or unreasonable choices of parameters. It is recommended to use the plot option to double check the plausibility of the results.
- Parameters
time_series (np.ndarray) – time series to calculate dimension of, shape (T, d)
r_minmin (float) – minimum radius in grid search
r_maxmax (float) – maximum radius in grid search
nr_steps (int) – number of steps in grid search
plot – flag for plotting loglog plot
- rescomp.measures.divergence_time(pred_time_series, meas_time_series, epsilon)¶
Calculates how long it takes for measurement and prediction to diverge
Measure for the quality of the predicted trajectory
The divergence time refers to the number of time_steps it takes for the predicted trajectory to diverge from the measured trajectory by more than a given distance in one or more dimensions. The distance measure is the supremum norm, NOT the euclidean one.
- Parameters
pred_time_series (np.ndarray) – predicted/simulated data, shape (T, d)
meas_time_series (np.ndarray) – observed/measured/real data, shape (T, d)
epsilon (float or np.ndarray) – Distance threshold, above which the two time series count as diverged. Either float or 1D-array with length d.
- Returns
- divergence_time, the number of time steps for which
meas_time_series and pred_time_series are separated by less than epsilon in each dimension.
- Return type
int
- rescomp.measures.rmse(pred_time_series, meas_time_series, normalization=None)¶
Calculates the root mean squared error between two time series
The time series must be of equal length and dimension
- Parameters
pred_time_series (np.ndarray) – predicted/simulated data, shape (T, d)
meas_time_series (np.ndarray) – observed/measured/real data, shape (T, d)
normalization (str_or_None_or_float) –
The normalization method to use. Possible are:
None: Calculates the pure, standard RMSE
”mean”: Calulates RMSE divided by the measured time series mean
”std_over_time”: Calulates RMSE divided by the measured time series’ standard deviation in time of dimension. See the NRSME definition of Vlachas, Pathak et al. (2019) for details
float: Calulates the RMSE, then divides it by the given float
”2norm”: Uses the vector 2-norm of the meas_time_series to normalize the RMSE for each time step
”maxmin”: Divides the RMSE by (max(meas) - min(meas))
”historic”: Old, weird way to normalize the NRMSE, kept here purely for backwards compatibility. Don’t use if you are not 100% sure that’s what you want.
- Returns
RMSE or NRMSE
- Return type
float
- rescomp.measures.rmse_over_time(pred_time_series, meas_time_series, normalization=None)¶
Calculates the NRMSE over time,
- Parameters
pred_time_series (np.ndarray) – predicted/simulated data, shape (T, d)
meas_time_series (np.ndarray) – observed/measured/real data, shape (T, d)
normalization (str_or_None_or_float) –
The normalization method to use. Possible are:
None: Calculates the pure, standard RMSE
”mean”: Calulates RMSE divided by the entire, flattened meas_time_series mean
”std_over_time”: Calulates RMSE divided by the entire meas_time_series’ standard deviation in time of dimension. See Vlachas, Pathak et al. (2019) for details
”2norm”: Uses the vector 2-norm of the meas_time_series averaged over time normalize the RMSE for each time step
”maxmin”: Divides the RMSE by (max(meas) - min(meas))
float: Calulates the RMSE, then divides it by the given float
- Returns
RMSE for each time step, shape (T,)
- Return type
np.ndarray