src.dackar.anomalies.t_score¶
Created on July, 2025
@author: wangc, mandd
Attributes¶
Functions¶
|
Method designed to extract a portion of a time series |
|
Method designed to extract set of portions of a time series |
|
Method designed to randomly choose Nsamples out of an array (replace is set to True) |
|
Method designed to calculate the statistical difference between two arrays using t-test |
|
Method designed to calculate the statistical difference between an array and a set of arrays |
|
Method designed to assess temporal correlation of an event E and a time series TS |
Module Contents¶
- src.dackar.anomalies.t_score.getL(loc, window, array, type)[source]¶
Method designed to extract a portion of a time series
- Parameters:
loc – int, reference location in the time series for the selected portion
window – np.array, size of the selected portion of the time series
array – np.array, original time series
type – string, type of the selected portion of the time series (rear or front)
- Returns:
np array, size of the selected portion of the time series
- Return type:
timeseriesPortion
- src.dackar.anomalies.t_score.omega(window, array, Nsamples)[source]¶
Method designed to extract set of portions of a time series
- Parameters:
window – np.array, size of the selected portion of the time series
array – np.array, original time series
Nsamples – int, number of portions to be selected
- Returns:
np.array, set of Nsamples portions of a time series
- Return type:
omegaSet
- src.dackar.anomalies.t_score.choice(array, Nsamples)[source]¶
Method designed to randomly choose Nsamples out of an array (replace is set to True)
- Parameters:
array – np.array, array of values to be sampled
Nsamples – int, number of elements of array to be selected
- Returns:
np.array, set of Nsamples elements randomly chosen from array
- Return type:
sampled
- src.dackar.anomalies.t_score.t_score(array_front, array_rear)[source]¶
Method designed to calculate the statistical difference between two arrays using t-test
- Parameters:
array_front – np.array, first array
array_rear – np.array, second array
- Returns:
float, outcome of t-test
- Return type:
tscore
- src.dackar.anomalies.t_score.MMD_test(test_array, omegaSet, iterations, alphaTest, alphaOmegaset, printFlag=True)[source]¶
Method designed to calculate the statistical difference between an array and a set of arrays using the Maximum Mean Discrepancy testing method
- Parameters:
test_array – np.array, array of values to be tested against omegaSet
omegaSet – np.ndarray or list, population of arrays
iterations – int, number of iterartions required to compute MMD^2_u
alphaTest – float, acceptance value for hypothesis testing (single array testing)
alphaOmegaset – float, acceptance value for hypothesis testing (omegaSet testing)
printFlag – bool, flag to plot MMD distribution
- Returns:
float, p-value obtained from MMD testing testOutput: bool, logical outcome of MMD testing
- Return type:
p_value
- src.dackar.anomalies.t_score.event2TStest(E_loc, TS, iterations, alphaTest, alphaOmegaset, windowSize, omegaSize, returnMinPval=False)[source]¶
Method designed to assess temporal correlation of an event E and a time series TS
- Parameters:
E_loc – int, temporal location of event E
TS – np.array, univariate time series
iterations – int, number of iterartions required to compute MMD^2_u
alphaTest – float, acceptance value for hypothesis testing (single array testing)
alphaOmegaset – float, acceptance value for hypothesis testing (omegaSet testing)
windowSize – int, size of time window prior and after event occurence
omegaSize – int, number of samples from time series TS
returnMinPval – bool, flag that indictae whether to return p-value of MMD assessment
- Returns:
string, outcome of the event to timeseries temporal analysis minPval: float, p-value of MMD assessment
- Return type:
relation