From 69cce1abf17cf89b6bd9895027ce24d9e3465c7b Mon Sep 17 00:00:00 2001 From: Shunsuke Kanda Date: Sun, 3 Nov 2024 16:35:38 +0900 Subject: [PATCH] Use n_topics (#57) --- src/statistical_tests/bootstrap_test.rs | 7 +++++++ src/statistical_tests/student_t_test.rs | 12 +++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/statistical_tests/bootstrap_test.rs b/src/statistical_tests/bootstrap_test.rs index 3333793..3f0cf47 100644 --- a/src/statistical_tests/bootstrap_test.rs +++ b/src/statistical_tests/bootstrap_test.rs @@ -38,6 +38,7 @@ use crate::statistical_tests::student_t_test::compute_t_stat; /// SIGIR 2006. #[derive(Debug, Clone, Copy)] pub struct BootstrapTest { + n_topics: usize, n_resamples: usize, random_state: u64, p_value: f64, @@ -60,6 +61,11 @@ impl BootstrapTest { BootstrapTester::new().test(samples) } + /// Number of topics, $`n`$. + pub const fn n_topics(&self) -> usize { + self.n_topics + } + /// Number of resamples. pub const fn n_resamples(&self) -> usize { self.n_resamples @@ -162,6 +168,7 @@ impl BootstrapTester { let p_value = count as f64 / self.n_resamples as f64; Ok(BootstrapTest { + n_topics: samples.len(), n_resamples: self.n_resamples, random_state, p_value, diff --git a/src/statistical_tests/student_t_test.rs b/src/statistical_tests/student_t_test.rs index 02bd1a4..f7ca4ed 100644 --- a/src/statistical_tests/student_t_test.rs +++ b/src/statistical_tests/student_t_test.rs @@ -46,7 +46,7 @@ use crate::errors::Result; /// ``` #[derive(Debug, Clone)] pub struct StudentTTest { - n_samples: usize, + n_topics: usize, mean: f64, variance: f64, t_stat: f64, @@ -78,7 +78,7 @@ impl StudentTTest { let p_value = t_dist.sf(t_stat.abs()) * 2.0; // two-tailed let scaled_t_dist = StudentsT::new(0.0, (variance / n).sqrt(), n - 1.0).unwrap(); Ok(Self { - n_samples: samples.len(), + n_topics: samples.len(), mean, variance, t_stat, @@ -87,9 +87,15 @@ impl StudentTTest { }) } + /// Number of topics, $`n`$. + pub const fn n_topics(&self) -> usize { + self.n_topics + } + /// Number of samples, $`n`$. + #[deprecated(since = "0.5.0", note = "Use `n_topics` instead.")] pub const fn n_samples(&self) -> usize { - self.n_samples + self.n_topics } /// Mean of the samples.