4 ms·
Oops, I left out this part: fn joint_kernel_density(x_data: &Array1<f64>, y_data: &Array1<f64>, x: f64, y: f64, bandwidth: f64) -> f64 { let normal
by eigenvalue 3y ago
Oops, I left out this part:
fn joint_kernel_density(x_data: &Array1<f64>, y_data: &Array1<f64>, x: f64, y: f64, bandwidth: f64) -> f64 {
let normal = Normal::new(0.0, bandwidth).unwrap();
let density: f64 = x_data.par_iter().zip(y_data.par_iter()).map(|(&x_val, &y_val)| {
normal.pdf((x - x_val) / bandwidth) * normal.pdf((y - y_val) / bandwidth)
}).sum();
density / ((x_data.len() as f64) * (bandwidth * bandwidth))
}