MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / predict_linear

Function predict_linear

nodedb/src/control/promql/functions.rs:111–115  ·  view source on GitHub ↗

`predict_linear(v range-vector, t scalar)` — extrapolate value at t seconds from now.

(samples: &[Sample], t_secs: f64)

Source from the content-addressed store, hash-verified

109
110/// `predict_linear(v range-vector, t scalar)` — extrapolate value at t seconds from now.
111pub fn predict_linear(samples: &[Sample], t_secs: f64) -> Option<f64> {
112 let slope = deriv(samples)?;
113 let last = samples.last()?;
114 Some(last.value + slope * t_secs)
115}
116
117/// `avg_over_time(v range-vector)` — average value over the range.
118pub fn avg_over_time(samples: &[Sample]) -> Option<f64> {

Callers 1

call_range_funcFunction · 0.85

Calls 2

derivFunction · 0.85
lastMethod · 0.45

Tested by

no test coverage detected