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

Function get_weights_ffd

crates/openquant/src/fracdiff.rs:17–38  ·  view source on GitHub ↗
(diff_amt: f64, thresh: f64, lim: usize)

Source from the content-addressed store, hash-verified

15}
16
17pub fn get_weights_ffd(diff_amt: f64, thresh: f64, lim: usize) -> Vec<f64> {
18 if lim == 0 {
19 return Vec::new();
20 }
21 let mut weights = vec![1.0];
22 let mut k = 1usize;
23 let mut ctr = 0usize;
24 loop {
25 let next = -weights[weights.len() - 1] * (diff_amt - k as f64 + 1.0) / k as f64;
26 if next.abs() < thresh {
27 break;
28 }
29 weights.push(next);
30 k += 1;
31 ctr += 1;
32 if ctr == lim - 1 {
33 break;
34 }
35 }
36 weights.reverse();
37 weights
38}
39
40pub fn frac_diff(series: &[f64], diff_amt: f64, thresh: f64) -> Vec<f64> {
41 let n = series.len();

Callers 3

frac_diff_ffdFunction · 0.85
test_get_weights_ffdFunction · 0.85
fracdiff_get_weights_ffdFunction · 0.85

Calls 1

lenMethod · 0.80

Tested by 1

test_get_weights_ffdFunction · 0.68