() Inputs: Time_Array, , |
% The transition time instances are stored in Time_Array; (>1) is the |
initial number of clusters (set by the user and will be the same for all the |
transitions); and is the total number of transition time instances % |
() Outputs: Clus_Avg , Clus_Max, Clus_Prob, |
% Clus_Avg stores the mean values of the clusters (average transition |
times); Clus_Max stores the highest-valued instance of each cluster |
(maximum transition times); Clus_Prob stores the support of each cluster |
(transition time probabilities); and is the final number of clusters % |
() declare and initialize Clus_Avg, Clus_Max and Clus_Prob |
% all the arrays are filled with zeros % |
() call function Introsort(Time_Array) % apply Introsort algorithm to sort Time_Array % |
% code for single cluster % |
() if (Time_Array − Time_Array) < (user-defined) threshold value |
then |
() for to do |
() Clus_Avg = Clus_Avg + Time_Array; |
end for |
() if Clus_Avg then |
() Clus_Avg = Clus_Avg; Clus_Max = Time_Array; |
() Clus_Prob; ; |
% code for (probable) multiple clusters % |
() else |
() declare and initialize Gap_Val[], Pos and |
% Gap_Val and Pos are filled with −1’s; Gap_Val keeps track of |
the () largest “GAP”s in the sorted number line (or Time_Array); |
Pos stores the corresponding array positions (ending points of clusters or “breaks”); |
and (>0) is a small integer number (user-defined) % |
() for to do |
() var gap = (Time_Array − Time_Array/(Time_Array; |
% calculate GAP between two instances; var implies Temporary Variable % |
() var min = Gap_Val; var minIndex = 0; |
() for to do |
() if Gap_Val < min then |
() min = Gap_Val; minIndex = ; |
end for |
() if gap > min then |
() Gap_ValminIndex = gap; PosminIndex = ; |
end for |
() call function Introsort(Pos) % apply Introsort() to sort Pos % |
% split the array into partitions (based on sorted () positions in Pos); |
then, calculate the mean of each partition and store them in Clus_Avg % |
() for to do |
() var temp1 = −1; var temp2 = −1; |
() if then |
() temp1 = 0; temp2 = Pos; |
() else if then |
() temp1 = Pos; temp2 = Pos; |
() else |
() temp1 = Pos; temp2 = ; |
() for = temp1 to temp2 do |
() Clus_Avg = Clus_Avg + Time_Array; |
end for |
() if Clus_Avg then |
() Clus_Avg = Clus_Avg/(temp2 − temp1 + 1); |
end for |
% pass the newly calculated mean values (stored in Clus_Avg) as the |
initial cluster centers to the (traditional) -means algorithm % |
() call function _Means_Algorithm(Time_Array, , , Clus_Avg, Pos); |
% Apply HAC algorithm to merge the clusters whose centers are not far away |
(in a user-defined way) from each other % |
() call function HAC_Algorithm(Time_Array, , , Pos, Clus_Avg, Clus_Max, Clus_Prob); |
% the average and maximum transition times of the clusters and their corresponding |
probabilities can be found in Clus_Avg, Clus_Max and |
Clus_Prob, respectively from 0th to ()th position % |
() Save the clustering results into the file and Exit the procedure |