Re: VALUE_LOCATE tutorial [message #66996] |
Fri, 26 June 2009 08:54 |
Jeremy Bailin
Messages: 618 Registered: April 2008
|
Senior Member |
|
|
On Jun 25, 5:14 pm, "Kenneth P. Bowman" <k-bow...@null.edu> wrote:
> In article <ywkuk530jtjl....@snowblow.colorado.edu>, sav...@nsidc.org
> wrote:
>
>> Jeremy Bailin <astroco...@gmail.com> writes:
>
>> I think the main reason it's not used is because it's so poorly named.
>> How would you find this if you just wanted to partition some data? I
>> can't remember who pointed it out to me first, but I do remember
>> thinking to myself, "Hmm, that's useful, wonder why I've never heard of
>> it".
>
>> Cheers,
>> Matt
>
> I think they knew that if they named it SEARCH it would conflict with
> thousands of user-written routines. :-)
>
> Ken
Pre-5.3, I had a homebrewed version of it called BSEARCH, that I
thought was pretty efficient but which gets blown out of the water by
VALUE_LOCATE!
-Jeremy.
|
|
|
Re: VALUE_LOCATE tutorial [message #67012 is a reply to message #66996] |
Thu, 25 June 2009 16:57  |
ben.bighair
Messages: 221 Registered: April 2007
|
Senior Member |
|
|
On Jun 25, 7:00 pm, David Fanning <n...@dfanning.com> wrote:
> ben.bighair writes:
>> If I recall correctly, there is a function in Numerical Recipes for C
>> called locate() that does the bifurcation search on an ordered list
>> that VALUE_LOCATE does. Perhaps that is the origin of the name?
>
> If I'm not mistaken, Al Gore had the original idea for this function.
>
Hmmm. A plurality programmers thought so, too. But the software
judges overruled the will of the masses on this one, too.
Cheers,
Ben
t
P.S. I found this (http://www.nrbook.com/ub30001/nr3-3-1.pdf) but it
doesn't look like the plain old incomprehensible C that I never
figured out. Anyway, there is a routine called locate in there.
|
|
|
Re: VALUE_LOCATE tutorial [message #67016 is a reply to message #67012] |
Thu, 25 June 2009 16:00  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
ben.bighair writes:
> If I recall correctly, there is a function in Numerical Recipes for C
> called locate() that does the bifurcation search on an ordered list
> that VALUE_LOCATE does. Perhaps that is the origin of the name?
If I'm not mistaken, Al Gore had the original idea for this function.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
Re: VALUE_LOCATE tutorial [message #67017 is a reply to message #67016] |
Thu, 25 June 2009 15:48  |
ben.bighair
Messages: 221 Registered: April 2007
|
Senior Member |
|
|
On Jun 25, 5:21 pm, "Kenneth P. Bowman" <k-bow...@null.edu> wrote:
> I think VALUE_LOCATE may have come out of this discussion
>
> http://groups.google.com/group/comp.lang.idl-pvwave/browse_t hread/thr...
>
> back in 1998.
>
> I think I submitted an official feature request to what was then RSI, and
> in my own mind I like to take credit for VALUE_LOCATE. :-)
>
> Ken
Hi,
If I recall correctly, there is a function in Numerical Recipes for C
called locate() that does the bifurcation search on an ordered list
that VALUE_LOCATE does. Perhaps that is the origin of the name?
Cheers,
Ben
|
|
|
|
|
Re: VALUE_LOCATE tutorial [message #67035 is a reply to message #67021] |
Thu, 25 June 2009 07:07  |
Matt[2]
Messages: 69 Registered: March 2007
|
Member |
|
|
Jeremy Bailin <astroconst@gmail.com> writes:
> There are probably two reasons why VALUE_LOCATE is underused. The
> first is that it was only introduced in IDL 5.3, well after many
> people developed their core techniques. The second is that the help
> page is somewhat opaque on what it actually does. The basic idea is
> pretty simple: given two arrays Values and Array,
I think the main reason it's not used is because it's so poorly named.
How would you find this if you just wanted to partition some data? I
can't remember who pointed it out to me first, but I do remember
thinking to myself, "Hmm, that's useful, wonder why I've never heard of
it".
Cheers,
Matt
--
Matthew Savoie - Scientific Programmer
National Snow and Ice Data Center
(303) 735-0785 http://nsidc.org
|
|
|
Re: VALUE_LOCATE tutorial [message #67042 is a reply to message #67035] |
Wed, 24 June 2009 15:20  |
Jeremy Bailin
Messages: 618 Registered: April 2008
|
Senior Member |
|
|
There's one more important application for Value_Locate that I meant
to include!
(David - you can stick this after the "Using Ranges For Partitioning"
subsection)
- Using Ranges In An Interpolation Scheme -
Another convenient use of this property of Value_Locate is for
interpolation. Most interpolation schemes work by fitting a low-order
polynomial or similar function to the points near the desired
location. How do you efficiently determine which points are the "near
points"? Using Value_Locate!
The simplest example is a linear interpolation between the
neighbouring points: if x[i] <= array[j] <= x[i+1] (where x is
strictly increasing) then the interpolated value is:
interpolated_y[j] = y[i] * (x[i+1]-array[j])/(x[i+1]-x[i]) + y[i+1] *
(array[j]-x[i])/(x[i+1]-x[i])
The trick is to figure out which i to use for a given j... but that's
exactly what Value_Locate does! Here is some simple code that will
calculate this interpolation (I haven't taken care to handle the edge
cases correctly, but see the code of the library function Interpol for
more details):
left = Value_Locate(x, array)
right = left+1
interpolated_y = y[left] * (x[right]-array)/(x[right]-x[left]) + y
[right] * (array-x[left])/(x[right-x[left])
This is equivalent to Interpol(y, x, array).
-Jeremy.
|
|
|
|
|