Calculate how much a set of boxes is homogenously distributed or contentrated within one dimension, returning the range_quintile of of the overlap counts per cell in a uniform partition of the extent of the dimension.
A uniform distribution of counts will have a small range and will require few cells in a selectivity histogram. A diverse distribution of counts will have a larger range and require more cells in a selectivity histogram (to distinguish between areas of feature density and areas of feature sparseness. This measurement should help us identify cases like X/Y/Z data where there is lots of variability in density in X/Y (diversely in a multi-kilometer range) and far less in Z (in a few-hundred meter range).
Definition at line 736 of file gserialized_estimate.c.
References ND_BOX_T::max, MAX_DIMENSION_WIDTH, ND_BOX_T::min, NUM_BINS, range_quintile(), and TRUE.
Referenced by compute_gserialized_stats_mode().
742 #if POSTGIS_DEBUG_LEVEL >= 3 743 double average, sdev, sdev_ratio;
749 for ( d = 0; d < ndims; d++ )
752 memset(counts, 0,
sizeof(counts));
754 smin = extent->
min[d];
755 smax = extent->
max[d];
756 swidth = smax - smin;
770 for ( i = 0; i < num_boxes; i++ )
772 double minoffset, maxoffset;
776 if ( ! ndb )
continue;
779 minoffset = ndb->
min[d] - smin;
780 maxoffset = ndb->
max[d] - smin;
783 if ( minoffset < 0 || minoffset > swidth ||
784 maxoffset < 0 || maxoffset > swidth )
790 bmin = floor(
NUM_BINS * minoffset / swidth);
791 bmax = floor(
NUM_BINS * maxoffset / swidth);
797 POSTGIS_DEBUGF(4,
" dimension %d, feature %d: bin %d to bin %d", d, i, bmin, bmax);
800 for ( k = bmin; k <= bmax; k++ )
810 #if POSTGIS_DEBUG_LEVEL >= 3 813 sdev_ratio = sdev/average;
815 POSTGIS_DEBUGF(3,
" dimension %d: range = %d", d, range);
816 POSTGIS_DEBUGF(3,
" dimension %d: average = %.6g", d, average);
817 POSTGIS_DEBUGF(3,
" dimension %d: stddev = %.6g", d, sdev);
818 POSTGIS_DEBUGF(3,
" dimension %d: stddev_ratio = %.6g", d, sdev_ratio);
821 distribution[d] = range;
static int range_quintile(int *vals, int nvals)
The difference between the fourth and first quintile values, the "inter-quintile range".
#define MAX_DIMENSION_WIDTH
Maximum width of a dimension that we'll bother trying to compute statistics on.
N-dimensional box type for calculations, to avoid doing explicit axis conversions from GBOX in all ca...