MCPcopy Create free account
hub / github.com/Open-Quant/openquant / frac_diff_ffd

Function frac_diff_ffd

crates/openquant/src/fracdiff.rs:73–93  ·  view source on GitHub ↗
(series: &[f64], diff_amt: f64, thresh: f64)

Source from the content-addressed store, hash-verified

71}
72
73pub fn frac_diff_ffd(series: &[f64], diff_amt: f64, thresh: f64) -> Vec<f64> {
74 let n = series.len();
75 if n == 0 {
76 return Vec::new();
77 }
78 let weights = get_weights_ffd(diff_amt, thresh, n);
79 if weights.is_empty() {
80 return vec![f64::NAN; n];
81 }
82 let width = weights.len() - 1;
83 let mut out = vec![f64::NAN; n];
84 for iloc in width..n {
85 let loc0 = iloc - width;
86 let mut acc = 0.0;
87 for (k, w) in weights.iter().enumerate() {
88 acc += *w * series[loc0 + k];
89 }
90 out[iloc] = acc;
91 }
92 out
93}

Callers 2

test_frac_diff_ffdFunction · 0.85
fracdiff_frac_diff_ffdFunction · 0.85

Calls 3

get_weights_ffdFunction · 0.85
lenMethod · 0.80
is_emptyMethod · 0.80

Tested by 1

test_frac_diff_ffdFunction · 0.68