in reply to Re^5: Can I speed this up?
in thread Can I speed this up? (repetitively scanning ranges in a large array)

The potential maxima are at the center of your ranges. Since the peaks are all the same size (ranges being all 5k wide, and the same slope (+/-1 per unit distance) then the minima will be at the half way point between two maxima.

4k |-   / \  / \    / \ / \       /
2k |-  /   \/   \  /       \     /
0k |- /          \/         \___/

Since you know where the peaks are (start+2.5k), and you can sort the ranges by start position, you can trivially identify the neighboring ranges. Halfway between the peak of range N and range N+1, there might be a local minima, or a flat spot, as in the picture.

The value at the minima will be easily calculated once located by finding the distance to either of the two ranges causing it.

Replies are listed 'Best First'.
Re^7: Finding Local Minima
by daverave (Scribe) on Nov 02, 2010 at 13:58 UTC
    I'm still thinking about this, but one thing I should note right away is that ranges are not all of the same width. 5k is some average, actual lengths are different and typically range between 500 - 20k.

    This also raises the question of what are neighboring ranges? Those with nearest centers? nearest edges?

    Id you could give the basic loop your idea refers to I could combine it in the code previously published and see if it makes sense.