pub struct TimeFunc(pub Vec<(DateTime<Utc>, f64)>);
Expand description
A vector of data points that we can use to analyse time series data. Each data point is valid from the previous timestamp until its current timestamp. If it is the first point of data then it is only valid for a total time of 0.
.B
| /\ |
| / \ |
| / \ |
| / \ |
A./ \.C
__________|__________|_________
Invalid | Valid | Invalid
_______________________________
. . .
A B C
Tuple Fields§
§0: Vec<(DateTime<Utc>, f64)>
Implementations§
Source§impl TimeFunc
impl TimeFunc
Sourcepub fn get_moving_average(&self, time: DateTime<Utc>, duration: Duration) -> f64
pub fn get_moving_average(&self, time: DateTime<Utc>, duration: Duration) -> f64
Gets the average of the function from time, to time - duration This function isn’t perfects acurate as it uses the closest available indeces, and does not interpolate
Sourcepub fn get_integral_interpolated(
&self,
time: DateTime<Utc>,
duration: Duration,
) -> f64
pub fn get_integral_interpolated( &self, time: DateTime<Utc>, duration: Duration, ) -> f64
Gets the average of the function from time, to time - duration This function interpolates the function and uses exact positions
Sourcepub fn get_average_interpolated(
&self,
time: DateTime<Utc>,
duration: Duration,
) -> f64
pub fn get_average_interpolated( &self, time: DateTime<Utc>, duration: Duration, ) -> f64
Gets the linear interpolated average of the function
Sourcepub fn get_rms(&self, duration: Duration, time: DateTime<Utc>) -> f64
pub fn get_rms(&self, duration: Duration, time: DateTime<Utc>) -> f64
Get’s the normalized RMS Does not use interpolation as of yet
pub fn get_rms_timefunc(&self, duration: Duration) -> Self
pub fn get_inflation(&self, duration: Duration, time: DateTime<Utc>) -> f64
pub fn get_inflation_interpolated( &self, duration: Duration, time: DateTime<Utc>, ) -> f64
pub fn get_inflation_timefunc(&self, duration: Duration) -> Self
pub fn get_inflation_interpolated_timefunc(&self, duration: Duration) -> Self
pub fn get_index(&self, time: &DateTime<Utc>) -> Result<usize, usize>
pub fn get_index_safe(&self, time: &DateTime<Utc>) -> usize
pub fn get_index_above(&self, time: &DateTime<Utc>) -> usize
pub fn get_index_below(&self, time: &DateTime<Utc>) -> usize
Sourcepub fn get_fractional_index(
&self,
time: &DateTime<Utc>,
) -> Result<f64, Box<dyn Error>>
pub fn get_fractional_index( &self, time: &DateTime<Utc>, ) -> Result<f64, Box<dyn Error>>
Returns the fractional index of a specific time
pub fn get_value(&self, time: DateTime<Utc>) -> f64
pub fn get_value_interpolated(&self, time: &DateTime<Utc>) -> f64
pub fn push( &mut self, point: (DateTime<Utc>, f64), ) -> Result<(), Box<dyn Error>>
Sourcepub fn verify(&self) -> Result<(), Box<dyn Error>>
pub fn verify(&self) -> Result<(), Box<dyn Error>>
Verifies that the timefunc is valid. Checks to ensure the list is sorted and deduped.
Sourcepub fn is_deduped(&self) -> bool
pub fn is_deduped(&self) -> bool
Verifies that the function is deduped Assumes vec is sorted is sorted.