From 33e86633d26c72806de88984c603e1bf9c4a5c05 Mon Sep 17 00:00:00 2001 From: Stephen Waits Date: Mon, 15 May 2023 12:09:13 -0600 Subject: [PATCH] minor cleanup Signed-off-by: Stephen Waits --- src/main.rs | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/main.rs b/src/main.rs index 2a58ea4..422f0c8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -118,18 +118,15 @@ fn permutation_test(control: &[f64], treatment: &[f64], mu_diff: f64) -> f64 { } // convert p-value to conventional language -fn pvalue_to_str(p: f64) -> String { - if p < 0.01 { - "very strong evidence agaisnt null hypothesis".to_string() - } else if p < 0.025 { - "strong evidence against null hypothesis".to_string() - } else if p < 0.05 { - "reasonably strong evidence against null hypothesis".to_string() - } else if p < 0.10 { - "borderline evidence against null hypothesis".to_string() - } else { - "no evidence against null hypothesis".to_string() +fn pvalue_to_string(p: f64) -> String { + match p { + p if p < 0.01 => "very strong evidence against null hypothesis", + p if p < 0.025 => "strong evidence against null hypothesis", + p if p < 0.05 => "reasonably strong evidence against null hypothesis", + p if p < 0.10 => "borderline evidence against null hypothesis", + _ => "no evidence against null hypothesis", } + .to_string() } // @@ -153,7 +150,7 @@ fn main() -> Result<()> { // run permutation test to compute p-value let pvalue = permutation_test(&control, &treatment, mean_treatment - mean_control); println!(" p-value = {}", pvalue); - println!(" result = {}", pvalue_to_str(pvalue)); + println!(" result = {}", pvalue_to_string(pvalue)); Ok(()) }