From cd9f00300cacbf91cd5ca3526666be3da22a1211 Mon Sep 17 00:00:00 2001 From: "Michael K. Borregaard" Date: Tue, 5 Sep 2017 15:40:11 +0200 Subject: [PATCH] Add correction for correlations --- src/recipes.jl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/recipes.jl b/src/recipes.jl index aeee2bc9..4105f7c5 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -505,9 +505,10 @@ function _auto_binning_nbins{N}(vs::NTuple{N,AbstractVector}, dim::Integer; mode _span(v) = ignorenan_maximum(v) - ignorenan_minimum(v) n_samples = length(linearindices(first(vs))) - # Estimator for number of samples in one row/column of bins along each axis: - nd = n_samples^(1/(2+N)) + # The nd estimator is the key to most automatic binning methods, and is modified for twodimensional histograms to include correlation + nd = n_samples^(1/(2+N)) + nd = N == 2 ? nd / (1-cor(first(vs), last(vs))^2)^(3//8) : nd # the >2-dimensional case does not have a nice solution to correlations v = vs[dim]