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

Function get_weights

crates/openquant/src/fracdiff.rs:3–15  ·  view source on GitHub ↗

Fractional differentiation utilities (AFML chapter 5 style).

(diff_amt: f64, size: usize)

Source from the content-addressed store, hash-verified

1//! Fractional differentiation utilities (AFML chapter 5 style).
2
3pub fn get_weights(diff_amt: f64, size: usize) -> Vec<f64> {
4 if size == 0 {
5 return Vec::new();
6 }
7 let mut weights = Vec::with_capacity(size);
8 weights.push(1.0);
9 for k in 1..size {
10 let w = -weights[k - 1] * (diff_amt - k as f64 + 1.0) / k as f64;
11 weights.push(w);
12 }
13 weights.reverse();
14 weights
15}
16
17pub fn get_weights_ffd(diff_amt: f64, thresh: f64, lim: usize) -> Vec<f64> {
18 if lim == 0 {

Callers 3

frac_diffFunction · 0.85
test_get_weightsFunction · 0.85
fracdiff_get_weightsFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_get_weightsFunction · 0.68