pub fn simple_moving_average(slice: &[f64]) -> Result<f64> {
	let length = slice.len();
	if length == 0 {
		return Err(AnalysisError::SliceIsEmpty);
	}
	Ok(slice.iter().fold(0., |sum, x| sum + x) / length as f64)
}
/// Simple moving average (SMA) is the unweighted mean of the datum points.
///
/// The number of periods depends on the analytical objectives. Typical number
/// of periods for short, medium and long term trends are 5-20, 20-60 and
/// 100-200 respectively.
///
/// # Arguments
///
/// * `slice` - array of values
///
/// # Example
///
/// ```
/// use stat::analysis::trend;
///
/// let array = [3.5, 3.4, 3.3, 3.6, 3.7];
/// let value = trend::simple_moving_average(&array);
/// assert_eq!(value.ok(), Some(3.5));
/// ```
Simple moving average (SMA) is the unweighted mean of the datum points.
The number of periods depends on the analytical objectives. Typical number
of periods for short, medium and long term trends are 5-20, 20-60 and
100-200 respectively.
Simple moving average ( SMA ) is the unweighted mean of the datum points . The number of periods depends on the analytical objectives . Typical number of periods for short medium and long term trends are 5 - 20 20 - 60 and 100 - 200 respectively .
pub fn simple_moving_average(slice: &[f64]) -> Result<f64> {
	let length = slice.len();
	if length == 0 {
		return Err(AnalysisError::SliceIsEmpty);
	}
	Ok(slice.iter().fold(0., |sum, x| sum + x) / length as f64)
}
pub fn simple_moving_average ( slice : & [ f64 ] ) -> Result < f64 > { let length = slice . len ( ) ; if length == 0 { return Err ( AnalysisError :: SliceIsEmpty ) ; } Ok ( slice . iter ( ) . fold ( 0. , | sum , x | sum + x ) / length as f64 ) }
Simple moving average (SMA) is the unweighted mean of the datum points.
Simple moving average ( SMA ) is the unweighted mean of the datum points .
slice
&[f64]
example
```
use stat::analysis::trend.


` ` ` use stat :: analysis :: trend .