`predict_linear(v range-vector, t scalar)` — extrapolate value at t seconds from now.
(samples: &[Sample], t_secs: f64)
| 109 | |
| 110 | /// `predict_linear(v range-vector, t scalar)` — extrapolate value at t seconds from now. |
| 111 | pub 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. |
| 118 | pub fn avg_over_time(samples: &[Sample]) -> Option<f64> { |
no test coverage detected