pub fn mean(nums: &[f64]) -> Option<f64> {
    if nums.is_empty() {
        Some(0.0)
    } else {
        let len = nums.len() as f64;
        let mut sum = 0.0;
        for i in &nums[..] {
            sum = sum + i;
        }
        Some(sum / len)
    }
}
/// Arithmetic mean of input values. The mean of an empty
/// list is 0.0.
///
/// # Examples:
///
/// ```
/// # use stats::*;
/// assert_eq!(Some(0.0), mean(&[]));
/// ```
/// ```
/// # use stats::*;
/// assert_eq!(Some(0.0), mean(&[-1.0, 1.0]));
/// ```
/// ```
/// # use stats::*;
/// assert_eq!(Some(1.0), mean(&[1.0]));
/// ```
Arithmetic mean of input values. The mean of an empty
list is 0.0.
Arithmetic mean of input values . The mean of an empty list is 0 . 0 .
pub fn mean(nums: &[f64]) -> Option<f64> {
    if nums.is_empty() {
        Some(0.0)
    } else {
        let len = nums.len() as f64;
        let mut sum = 0.0;
        for i in &nums[..] {
            sum = sum + i;
        }
        Some(sum / len)
    }
}
pub fn mean ( nums : & [ f64 ] ) -> Option < f64 > { if nums . is_empty ( ) { Some ( 0.0 ) } else { let len = nums . len ( ) as f64 ; let mut sum = 0.0 ; for i in & nums [ .. ] { sum = sum + i ; } Some ( sum / len ) } }
Arithmetic mean of input values.
Arithmetic mean of input values .
nums
&[f64]
nums
&[f64]
examples:
None
use stats::*;
None
use stats::*;
None
use stats::*;
None