From cd51dc6af23c41e63b06cae847282a9873851298 Mon Sep 17 00:00:00 2001 From: Alexander Date: Mon, 25 Apr 2022 11:03:20 +0300 Subject: initial commit correlation with rust add pearson correlation structure --- .gitignore | 1 + Cargo.lock | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 11 +++++++++++ src/main.rs | 35 +++++++++++++++++++++++++++++++++++ src/main.rs~ | 3 +++ 5 files changed, 98 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 src/main.rs create mode 100644 src/main.rs~ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..bc09f3f --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,48 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "GSL" +version = "4.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c90488c022c43f0009d7e804c4925b8975296b1c7aaca4cb18e3b434f809f7c" +dependencies = [ + "GSL-sys", + "paste", +] + +[[package]] +name = "GSL-sys" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbf44cd363ba6b685de2ead20a580ff72cee2e953285bd8ca8cc9208d58dace5" +dependencies = [ + "libc", + "pkg-config", +] + +[[package]] +name = "correlation_rust" +version = "0.1.0" +dependencies = [ + "GSL", +] + +[[package]] +name = "libc" +version = "0.2.124" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21a41fed9d98f27ab1c6d161da622a4fa35e8a54a8adc24bbf3ddd0ef70b0e50" + +[[package]] +name = "paste" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c520e05135d6e763148b6426a837e239041653ba7becd2e538c076c738025fc" + +[[package]] +name = "pkg-config" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..4c77327 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "correlation_rust" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] + +GSL = "4.0" + diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..1832f9b --- /dev/null +++ b/src/main.rs @@ -0,0 +1,35 @@ +use rgsl::{ + randist::t_distribution::{tdist_P, tdist_Q}, + statistics::{correlation, spearman}, +}; + + +trait Correlation { + fn correlate(&self,x:&[f64],y:&[f64]) ->(f64,f64); +} + +struct Pearson { + n: usize, + degree_of_freedom:f64, +} + +impl Pearson { + fn new(n:usize) -> Self { + + Self { + n, + degree_of_freedom:(n - 2) as f64, + } + } +} + + +impl Correlation for Pearson { + fn correlate(&self,x:&[f64],y:&[f64]) ->(f64,f64){ + (1.2,0.1) + } +} + +fn main() { + +} diff --git a/src/main.rs~ b/src/main.rs~ new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/src/main.rs~ @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} -- cgit 1.4.1