in reply to Re^2: Data range detection?
in thread Data range detection?
For evenly distributed, I was meaning choosing the distribution that most evenly spreads out the points. An exponential distribution on a linear axis will bunch everything up to the left, for example. Doing all the work to find out what "evenly distributed" is would be a headache. I hacked something together this morning that worked to select between linear and logarithmic in the number series you provided. To figure out the most "evenly distributed" version, I simply counted the number of points to the left of the midpoint and compared that to the number of points provided, selecting the series where the difference was the smallest.
From memory, it went something like:
sub check_list { my $r = shift; my ($min, $max) = minmax(@$r); my $ctr_lin = ($min+$max)/2; my $ctr_log = (log($min)+log($max))/2; my ($cnt_lin, $cnt_log)=(0,0); for (@$r) { ++$cnt_lin if $_ < $ctr_lin; ++$cnt_log if $_ < $ctr_log; } my $error_lin = abs($ctr_lin - @$r/2); my $error_log = abs($ctr_log - @$r/2); return $error_lin < $error_log ? "linear" : "log"; }
Update: I mentioned treating the axes separately, because some people were mentioning curve fitting (IIRC) which implied (to me) using both axes at the same time.
...roboticus
When your only tool is a hammer, all problems look like your thumb.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Data range detection?
by roboticus (Chancellor) on Apr 14, 2015 at 11:09 UTC |