# Testing distance of fitted spline curve with a constant curve

**URL:** <https://discourse.julialang.org/t/testing-distance-of-fitted-spline-curve-with-a-constant-curve/52225>\
**Category:** Community\
**Tags:** splines\
**Created:** [December 22, 2020, 11:57am UTC](https://discourse.julialang.org/t/testing-distance-of-fitted-spline-curve-with-a-constant-curve/52225 "2020-12-22T11:57:27Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![weera](https://avatars.discourse-cdn.com/v4/letter/w/a9a28c/32.png) [@weera](https://discourse.julialang.org/u/weera)\
**Post date:** [December 22, 2020, 11:57am UTC](https://discourse.julialang.org/t/testing-distance-of-fitted-spline-curve-with-a-constant-curve/52225/1 "2020-12-22T11:57:27Z")

</div>

I am using SmoothingSplines.jl package to fit a spline curve to a time series. What I need is to test the fitted curve with a prior constant curve. (I need to know how like an how close two curves are) Is there any package to do such test? any help will be appreciated.

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [December 22, 2020, 1:05pm UTC](https://discourse.julialang.org/t/testing-distance-of-fitted-spline-curve-with-a-constant-curve/52225/2 "2020-12-22T13:05:43Z")

</div>

How do your time series and reference curve look like?

---

<div class="post-metadata">

**Author:** ![weera](https://avatars.discourse-cdn.com/v4/letter/w/a9a28c/32.png) [@weera](https://discourse.julialang.org/u/weera)\
**Post date:** [December 22, 2020, 1:59pm UTC](https://discourse.julialang.org/t/testing-distance-of-fitted-spline-curve-with-a-constant-curve/52225/3 "2020-12-22T13:59:16Z")

</div>

Spline curve can be in any shape, but constant curve is a straight line

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [December 22, 2020, 5:30pm UTC](https://discourse.julialang.org/t/testing-distance-of-fitted-spline-curve-with-a-constant-curve/52225/4 "2020-12-22T17:30:48Z")

</div>

The area dissimilarity between the two curves as defined [here](https://www.mathworks.com/matlabcentral/answers/422967-how-to-calculate-the-area-dissimilarity-between-two-curves) seems to be an interesting metric and it does not require a package to compute it.

---

<div class="post-metadata">

**Author:** ![anon92994695](https://avatars.discourse-cdn.com/v4/letter/a/ce7236/32.png) [@anon92994695](https://discourse.julialang.org/u/anon92994695)\
**Post date:** [December 22, 2020, 5:56pm UTC](https://discourse.julialang.org/t/testing-distance-of-fitted-spline-curve-with-a-constant-curve/52225/5 "2020-12-22T17:56:11Z")

</div>

do you mean - how close you fit a spline to a curve, or the closest point on a spline to a curve?

---

<div class="post-metadata">

**Author:** ![weera](https://avatars.discourse-cdn.com/v4/letter/w/a9a28c/32.png) [@weera](https://discourse.julialang.org/u/weera)\
**Post date:** [December 22, 2020, 6:03pm UTC](https://discourse.julialang.org/t/testing-distance-of-fitted-spline-curve-with-a-constant-curve/52225/6 "2020-12-22T18:03:15Z")

</div>

I want to know if the two curves are convergent

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [December 22, 2020, 7:44pm UTC](https://discourse.julialang.org/t/testing-distance-of-fitted-spline-curve-with-a-constant-curve/52225/7 "2020-12-22T19:44:31Z")

</div>

> [@weera](#):
>
> I am using SmoothingSplines.jl package to fit a spline curve to a time series. What I need is to test the fitted curve with a prior constant curve.

Do you just want the integral \Vert f - g \Vert^2 = \int |f(x)-g(x)|^2 dx of the difference? You could use [QuadGK](https://github.com/JuliaMath/QuadGK.jl) for that, I guess.
