Skip to content

Commit

Permalink
Use n_topics (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
kampersanda authored Nov 3, 2024
1 parent b1b3b0e commit 69cce1a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/statistical_tests/bootstrap_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down
12 changes: 9 additions & 3 deletions src/statistical_tests/student_t_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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.
Expand Down

0 comments on commit 69cce1a

Please sign in to comment.