| 71 | } |
| 72 | |
| 73 | pub 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 | } |