Skip to content

Commit

Permalink
roms feature formula and test weights update
Browse files Browse the repository at this point in the history
  • Loading branch information
GaluTi committed Apr 25, 2024
1 parent 7c3221f commit 83f0a81
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/features/roms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ lazy_info!(
t_required: false,
m_required: true,
w_required: true,
sorting_required: true,
sorting_required: false,
);

impl FeatureNamesDescriptionsTrait for Roms {
Expand All @@ -65,7 +65,7 @@ where
ts.m.as_slice()
.iter()
.zip(ts.w.as_slice().iter())
.map(|(&m, &w)| ((m - m_median).abs() / w))
.map(|(&m, &w)| ((m - m_median).abs() * w.sqrt()))
.filter(|&x| x.is_finite())
.sum::<T>();
let value = tmp_sum / (n - T::one());
Expand All @@ -87,21 +87,21 @@ mod tests {
feature_test!(
roms,
[Roms::new()],
[1.0],
[2.6035533],
[1.0_f32, 2.0, 3.0, 4.0, 5.0],
[1.0_f32, 1.0, 2.0, 3.0, 5.0],
[1.0_f32, 1.0, 2.0, 2.0, 2.0],
[1.0_f32, 4.0, 1.0, 2.0, 4.0],
);

#[test]
fn roms_const_data() {
let eval = Roms::default();
let x = linspace(0.0_f32, 100.0, 10);
let x = linspace(0.0_f32, 10.0, 10);
let y = vec![1.0_f32, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0];
let z = vec![1.0_f32, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0];
let mut ts = TimeSeries::new(&x, &y, &z);
let actual = eval.eval(&mut ts).unwrap();
let desired = [0.0_f32];
all_close(&actual, &desired, 1e-10);
}

}

0 comments on commit 83f0a81

Please sign in to comment.