BrowserUk:

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.


In reply to Re^3: Data range detection? by roboticus
in thread Data range detection? by BrowserUk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.