about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlexander <alexanderkabua@gmail.com>2022-04-25 12:00:19 +0300
committerAlexander <alexanderkabua@gmail.com>2022-04-25 12:00:19 +0300
commitabd00921eb4e9ccdee7e598292614a2f10b3ac40 (patch)
tree24be677cc25e5a48ef8a6943a739d280c140932c /src
parent1b29624838a7fa867956c68e125f7b97a110deb6 (diff)
downloadcorrelation_rust-abd00921eb4e9ccdee7e598292614a2f10b3ac40.tar.gz
fix for tests
Diffstat (limited to 'src')
-rw-r--r--src/main.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index 7164d85..a0337a4 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -3,6 +3,7 @@ use rgsl::{
     statistics::{correlation, spearman},
 };
 
+use assert_approx_eq::assert_approx_eq;
 
 trait Correlation {
     fn correlate(&self,x:&[f64],y:&[f64]) ->(f64,f64);
@@ -33,7 +34,10 @@ impl Pearson {
 
 impl Correlation for Pearson {
     fn correlate(&self,x:&[f64],y:&[f64]) ->(f64,f64){
-        (1.2,0.1)
+
+        let corr_coeff = correlation(x, 1, y, 1, self.n);
+
+        (corr_coeff,0.1)
     }
 }
 
@@ -59,7 +63,7 @@ mod tests {
         let new_pearson = Pearson::new(3);
         let (corr_coeff,p_val) = new_pearson.correlate(&[1.,2.,3.,4.,5.] ,&[1.,2.,3.,4.,5.]);
 
-        assert_eq!(corr_coeff,1.2);
+        assert_eq!(format!("{:.2}", corr_coeff),"1.00");
         assert_eq!(p_val,0.1);
     }
 }
\ No newline at end of file