fn sample_covarience(arr: &Vec<(f32, f32)>) -> f32{
    let (mean_x, mean_y) = calculate_mean(&arr);
    let mut product_deviations_xy: f32 =0.0;
    let len = arr.len() as f32;

    for i in arr {
        let diff_x = i.0 - mean_x;
        let diff_y = i.1 - mean_y;
        let prod_xy = diff_x*diff_y;
        product_deviations_xy += prod_xy;
    }
    println!("prod_deviation_xy: {}", product_deviations_xy);
    let sample_cov = product_deviations_xy/(len-1.0);
    sample_cov
}
///The sample covariance is the average value of the product of the deviations of observations on two random variables from their
/// sample means:
/// Cov(X,Y)= Sum(Xi-mean_of_X)(Yi-mean_of_Y)/(n-1)
///sample_covariance takes in an array of tuples contains f32 values which represent the X and Y co-ordinates. The diffence between the X and X_mean and Y and Y_mean is calculated and their product taken. These are summed for all the values in the array. Sample covariance is calulated as the summation of the values described divided by sample size-1
The sample covariance is the average value of the product of the deviations of observations on two random variables from their
sample means:
Cov(X,Y)= Sum(Xi-mean_of_X)(Yi-mean_of_Y)/(n-1)
sample_covariance takes in an array of tuples contains f32 values which represent the X and Y co-ordinates. The diffence between the X and X_mean and Y and Y_mean is calculated and their product taken. These are summed for all the values in the array. Sample covariance is calulated as the summation of the values described divided by sample size-1
The sample covariance is the average value of the product of the deviations of observations on two random variables from their sample means : Cov ( X Y ) = Sum ( Xi - mean_of_X ) ( Yi - mean_of_Y ) / ( n - 1 ) sample_covariance takes in an array of tuples contains f32 values which represent the X and Y co - ordinates . The diffence between the X and X_mean and Y and Y_mean is calculated and their product taken . These are summed for all the values in the array . Sample covariance is calulated as the summation of the values described divided by sample size - 1
fn sample_covarience(arr: &Vec<(f32, f32)>) -> f32{
    let (mean_x, mean_y) = calculate_mean(&arr);
    let mut product_deviations_xy: f32 =0.0;
    let len = arr.len() as f32;
    for i in arr {
        let diff_x = i.0 - mean_x;
        let diff_y = i.1 - mean_y;
        let prod_xy = diff_x*diff_y;
        product_deviations_xy += prod_xy;
    }
    println!("prod_deviation_xy: {}", product_deviations_xy);
    let sample_cov = product_deviations_xy/(len-1.0);
    sample_cov
}
fn sample_covarience ( arr : & Vec < ( f32 , f32 ) > ) -> f32 { let ( mean_x , mean_y ) = calculate_mean ( & arr ) ; let mut product_deviations_xy : f32 = 0.0 ; let len = arr . len ( ) as f32 ; for i in arr { let diff_x = i . 0 - mean_x ; let diff_y = i . 1 - mean_y ; let prod_xy = diff_x * diff_y ; product_deviations_xy += prod_xy ; } println ! ( " " product_deviations_xy ) ; let sample_cov = product_deviations_xy / ( len - 1.0 ) ; sample_cov }
The sample covariance is the average value of the product of the deviations of observations on two random variables from their
sample means:
Cov(X,Y)= Sum(Xi-mean_of_X)(Yi-mean_of_Y)/(n-1)
sample_covariance takes in an array of tuples contains f32 values which represent the X and Y co-ordinates.
The sample covariance is the average value of the product of the deviations of observations on two random variables from their sample means : Cov ( X Y ) = Sum ( Xi - mean_of_X ) ( Yi - mean_of_Y ) / ( n - 1 ) sample_covariance takes in an array of tuples contains f32 values which represent the X and Y co - ordinates .
arr
&Vec<(f32, f32)>
arr
&Vec<(f32, f32)>