Function smartnoise_runtime::components::covariance::covariance [−][src]
pub fn covariance(
left: &ArrayView1<'_, Float>,
right: &ArrayView1<'_, Float>,
mean_left: Float,
mean_right: Float,
delta_degrees_of_freedom: usize
) -> Float
Get covariance between two 1D-arrays.
Arguments
left
- One of the two arrays for which you want the covariance.right
- One of the two arrays for which you want the covariance.mean_left
- Arithmetic mean of the left array.mean_right
- Arithmetic mean of the right array.delta_degrees_of_freedom
- 0 for population, 1 for finite sample correction
Return
Covariance of the two arrays.
Example
use ndarray::{ArrayD, arr1}; use smartnoise_runtime::components::covariance::covariance; let left = arr1(&[1.,2.,3.]); let right = arr1(&[4.,5.,6.]); let mean_left = 2.; let mean_right = 5.; let cov = covariance(&left.view(), &right.view(), mean_left, mean_right, 1); assert_eq!(cov, 1.);