@@ -30,10 +30,10 @@ void QuantitativeSynchronyAnalysisRequest::process_request(std::shared_ptr<Trans
3030
3131 if (t_data->time > current_t ) {
3232 current_t = t_data->time ;
33- while (recent_data_a.front ().time < current_t - temporal_sampling_rate) {
33+ while (recent_data_a.size () > 0 &&recent_data_a. front ().time < current_t - temporal_sampling_rate) {
3434 recent_data_a.pop_front ();
3535 }
36- while (recent_data_b.front ().time < current_t - temporal_sampling_rate) {
36+ while (recent_data_b.size () > 0 && recent_data_b. front ().time < current_t - temporal_sampling_rate) {
3737 recent_data_b.pop_front ();
3838 }
3939 std::vector<float > a_velocities;
@@ -96,7 +96,7 @@ TransformAnalysisType QuantitativeSynchronyAnalysisRequest::get_type() const {
9696// see: https://www.geeksforgeeks.org/program-spearmans-rank-correlation/
9797std::vector<float > QuantitativeSynchronyAnalysisRequest::rank_data (std::vector<float > const &data) {
9898 std::vector<float > ranks (data.size ());
99- float threshold = 0 .1f ;
99+ float threshold = 0 .00001f ;
100100 for (int i = 0 ; i < data.size (); i++) {
101101 int rank = 1 , same = 1 ;
102102
@@ -116,11 +116,11 @@ std::vector<float> QuantitativeSynchronyAnalysisRequest::rank_data(std::vector<f
116116}
117117
118118float QuantitativeSynchronyAnalysisRequest::correlation (const std::vector<float > &a, const std::vector<float > &b) {
119- if (a.size () != b.size ()) {
120- Debug::Log (" Error: Cannot calculate correlation between vectors of different sizes" );
119+ if (a.size () != b.size () || a. empty () ) {
120+ // Debug::Log("Error: Cannot calculate correlation between vectors of different sizes");
121121 return 0 ;
122122 }
123- float sum_a, sum_b, sum_ab, square_sum_a, square_sum_b = 0 ;
123+ float sum_a = 0 , sum_b = 0 , sum_ab = 0 , square_sum_a = 0 , square_sum_b = 0 ;
124124
125125 for (int i = 0 ; i < a.size (); i++) {
126126 sum_a = sum_a + a[i];
0 commit comments