# Is there any statistical method to compare two curves?

Is there any statistical method to visually compare two curves?

What is the best and correct way to compare two similar curves and calculate the error/difference in percentage?

I have created a program that generates a curve of a column base using Bezier curve. Now, I want to find out how accurate my generation is. So I have a function for the first curve I defined, but I dont have a function for the second one, which is only on the picture.

-
Are these curves functions, $y = f(x)$, or general curves in the plane like spirals, ellipses, etc.? – Rahul Apr 19 '14 at 19:16
general 2D curves, I am trying to compare curves I created using Bezier curve with the curve on the image (so I don't have function definitions for both of them) – Riko Apr 19 '14 at 19:20
but evaluation with certain number of vertices would be good enough, but how to calculate the error of the whole curve? I was thinking about (average deviation) / (curve length), but I'm not sure if this is statistically correct – Riko Apr 19 '14 at 19:23
or if there is any standard for such a evaluation... – Riko Apr 19 '14 at 19:24
Is the original curve parameterized? Is the Bezier curve parameterized? PS it might help if you put the actual equations into the question so we have some more context. – NotNotLogical Apr 19 '14 at 19:33

A standard way to compare two (sufficiently nice) functions $f(x)$ and $g(x)$ over the interval $[a,b]$ is to use the inner product $$\left<f(x),g(x)\right>:=\int_a^b{f(x)g(x)\,\mathrm{d}x}$$ from which we get $$||f(x)-g(x)||=\sqrt{\int_a^b{\left(f(x)-g(x)\right)^2\,\mathrm{d}x}}$$ where you can think of $||f(x)-g(x)||$ as being the "distance" between the functions $f$ and $g$.

If you are dealing with parametric curves you could use $$\text{dist}\,\left(x(t),y(t)\right):=\sqrt{\int_{t_0}^{t_1}{||x(t)-y(t)||^2\,\mathrm{d}t}}$$ to get a reasonable measure, but you would have to ensure that both curves are parameterized in the "same way".

EDIT: If you want a measure of "percent error" I suppose you could do something like $$\text{% error}=\frac{\text{magnitude of error}}{\text{original magnitude}}=\frac{\int{||x(t)-y(t)||\,\mathrm{d}t}}{\int{||x(t)||\,\mathrm{d}t}}$$ which is the integral of the difference divided by the arclength of the original path. Since you only have points, you would have to approximate by computing $$\frac{{\Delta t\over 10}\sum{||P_i-B_i||}}{\sum{\sqrt{(x_{i+1}-x_i)^2+(y_{i+1}-y_i)^2}}}$$ where $P_i=(x_i,y_i)$ is the $i$'th point on the path and $B_i$ is the corresponding point on the Bezier curve. So if the Bezier approximation is parameterized with $0\le t\le 1$ then $$B_i=y\left(i{1\over 10}\right)$$ where $y(t)$ is the curve.

Keep in mind that I'm making this up as I go ;) But hopefully you can work with some of these ideas and see if anything fits what you're wanting to get...

-
I am not sure, if this is what I need because I don't know the definition of g(x), I elaborated my question plz have a look – Riko Apr 19 '14 at 20:59
@Riko See the edit I've tried to change it accordingly – NotNotLogical Apr 19 '14 at 21:39
In discussing curve fitting, one uses this metric. However, there is a drawback of the error percentages: "Slim" column bases will get higher error percentages. I would suggest to standardise it somehow by the error of taking one solid block as the column base. But that's just a suggestion to review other possibilities. Some kind of total variation would also be reasonable. – Horst Grünbusch Apr 19 '14 at 22:16
@NotNotLogical Thanks for your answer, thinking of it: and please correct me if I am wrong, but since integral is the area between two curve segments, and taking into account that a segment between Pi and Pi+1 will be treated as a straight line segment, it would give me some error even if there was none in case that the corresponding B segment was not straight – Riko Apr 19 '14 at 22:49
If the points all match up, the sum in the numerator will be zero so you will get no error. – NotNotLogical Apr 19 '14 at 22:55

I think the best way is to overlay the new curve over the old one - such as putting the new curve on paper and laying it over the old curve. Do this on floor, or on a window pane to create a transparency effect and then take a digital caliper (or similar - ruler, etc.) and measure the offset between the two curves at as many points as you can.

The differences are your error. Make sure you record whether they are positive or negative, and as absolute value, as you may want to look at both total error and/or average error. Average error should be around zero if the new curve is proportioned correctly.

-