[SciPy-User] point-curve distance estimation or calculation

Matthieu Rigal rigal@rapideye...
Wed Jun 2 07:05:36 CDT 2010

Hi folks,

This is my first message on the scipy-user list. I post it here because I 
wanna try do the most out of it using numpy and scipy and I hope it is not 
too far from the initial scope. I couldn't finda solution to it on the 

First I have two sets of data. I am doing several leastsq optimizations.
for linear y=ax+b, I know how to handle the rest, for second order or more, 
it is more difficult.

In the y = ax²+bx+c case, I know have a curve. I want to calculate or 
estimate the distance between each point (combination of two data sets) 
and the curve.

Calculation is doable by applying this formula 
But then, an estimation of the correct result is required, and it takes a 
lot of time for every step, if you have 25 million values in each set.

First, there might be some functions useful to do this calculation quite 
fast (up to 5 minutes is quite acceptable), that I may have overseen. That 
may basically calculate the following internally 

Second, it may be better to get a close estimation of the distance to the 
curve. I was thinking about calculating the tangent of the curve at the 
(x, y0) point calculated from (x, y).
For this also, I didn't found a direct way of calculating the tangent else 
than calculating points very close to y0 and solve the equation. Are there 
some direct possibilities ?

Then I would simply calculate a distance from point to line, using one of 
following methods 

And so get an estimation. But also in this case, it seems quite complicated 
and not very efficient, so you may have a fully different idea :-))

Thanks for your hints,


RapidEye AG
Molkenmarkt 30
14776 Brandenburg an der Havel
Follow us on Twitter! www.twitter.com/rapideye_ag
Head Office/Sitz der Gesellschaft: Brandenburg an der Havel
Management Board/Vorstand: Wolfgang G. Biedermann
Chairman of Supervisory Board/Vorsitzender des Aufsichtsrates: 
Juergen Breitkopf 
Commercial Register/Handelsregister Potsdam HRB 17 796
Tax Number/Steuernummer: 048/100/00053
VAT-Ident-Number/Ust.-ID: DE 199331235
DIN EN ISO 9001 certified
Diese E-Mail enthaelt vertrauliche und/oder rechtlich geschuetzte
Informationen. Wenn Sie nicht der richtige Adressat sind oder diese
E-Mail irrtuemlich erhalten haben, informieren Sie bitte sofort den
Absender und vernichten Sie diese E-Mail. Das unerlaubte Kopieren sowie
die unbefugte Weitergabe dieser E-Mail ist nicht gestattet.
The information in this e-mail is intended for the named recipients
only. It may contain privileged and confidential information. If you
have received this communication in error, any use, copying or
dissemination of its contents is strictly prohibited. Please erase all
copies of the message along with any included attachments and notify
RapidEye AG or the sender immediately by telephone at the number
indicated on this page.

More information about the SciPy-User mailing list