From 6ca8471c64a45526ca45757f2bda388721bec82f Mon Sep 17 00:00:00 2001 From: "Michael K. Borregaard" Date: Fri, 6 Apr 2018 09:08:53 +0200 Subject: [PATCH] Improve histogram2d bin estimation The existing one would error when the correlation was high --- src/recipes.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/recipes.jl b/src/recipes.jl index 099d9b38..75075d02 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -562,7 +562,7 @@ function _auto_binning_nbins(vs::NTuple{N,AbstractVector}, dim::Integer; mode::S # 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 + nd = N == 2 ? min(n_samples^(1/(2+N)), 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]