From 9ce7537865b363be3f47d9d34d98bd2b4bfb8639 Mon Sep 17 00:00:00 2001 From: "Documenter.jl" Date: Sun, 18 Feb 2024 20:52:05 +0000 Subject: [PATCH] build based on fc1356d --- dev/.documenter-siteinfo.json | 2 +- dev/index.html | 2 +- dev/interface/index.html | 2 +- dev/manual/index.html | 2 +- dev/methods/{ecdc046b.svg => 1748e559.svg} | 82 ++-- dev/methods/{e15a5ffe.svg => 35f70a00.svg} | 86 ++-- dev/methods/{f8c8ddad.svg => 475d8590.svg} | 262 ++++++------ dev/methods/{e3964b5c.svg => 5511d890.svg} | 82 ++-- dev/methods/{ad4f683d.svg => 6db1f463.svg} | 82 ++-- dev/methods/{9ad2672e.svg => 803808eb.svg} | 86 ++-- dev/methods/{4dc6053f.svg => 98e50314.svg} | 82 ++-- dev/methods/{af6f43a5.svg => aec0f391.svg} | 96 ++--- dev/methods/{3335ea81.svg => b5d5784a.svg} | 262 ++++++------ dev/methods/{61d3525c.svg => b8a5ae51.svg} | 468 ++++++++++----------- dev/methods/{661d1020.svg => f32dc54c.svg} | 82 ++-- dev/methods/{c2fb34ca.svg => f7401cdf.svg} | 90 ++-- dev/methods/{c4fce43a.svg => f98894b4.svg} | 78 ++-- dev/methods/index.html | 28 +- 18 files changed, 937 insertions(+), 937 deletions(-) rename dev/methods/{ecdc046b.svg => 1748e559.svg} (97%) rename dev/methods/{e15a5ffe.svg => 35f70a00.svg} (97%) rename dev/methods/{f8c8ddad.svg => 475d8590.svg} (95%) rename dev/methods/{e3964b5c.svg => 5511d890.svg} (97%) rename dev/methods/{ad4f683d.svg => 6db1f463.svg} (97%) rename dev/methods/{9ad2672e.svg => 803808eb.svg} (97%) rename dev/methods/{4dc6053f.svg => 98e50314.svg} (97%) rename dev/methods/{af6f43a5.svg => aec0f391.svg} (86%) rename dev/methods/{3335ea81.svg => b5d5784a.svg} (95%) rename dev/methods/{61d3525c.svg => b8a5ae51.svg} (80%) rename dev/methods/{661d1020.svg => f32dc54c.svg} (97%) rename dev/methods/{c2fb34ca.svg => f7401cdf.svg} (97%) rename dev/methods/{c4fce43a.svg => f98894b4.svg} (97%) diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index 3f41a31d..9cdf12bc 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.10.1","generation_timestamp":"2024-02-18T11:13:22","documenter_version":"1.2.1"}} \ No newline at end of file +{"documenter":{"julia_version":"1.10.1","generation_timestamp":"2024-02-18T20:52:00","documenter_version":"1.2.1"}} \ No newline at end of file diff --git a/dev/index.html b/dev/index.html index 6f834811..3c64db91 100644 --- a/dev/index.html +++ b/dev/index.html @@ -249,4 +249,4 @@ [8e850b90] libblastrampoline_jll v5.8.0+1 [8e850ede] nghttp2_jll v1.52.0+1 [3f19e933] p7zip_jll v17.4.0+2 -Info Packages marked with ⌅ have new versions available but compatibility constraints restrict them from upgrading. To see why use `status --outdated -m`

You can also download the manifest file and the project file.

+Info Packages marked with ⌅ have new versions available but compatibility constraints restrict them from upgrading. To see why use `status --outdated -m`

You can also download the manifest file and the project file.

diff --git a/dev/interface/index.html b/dev/interface/index.html index d3c7d292..13ab549d 100644 --- a/dev/interface/index.html +++ b/dev/interface/index.html @@ -26,4 +26,4 @@ DataInterpolations.derivative(A2, 300.0)
-0.23144961208831108

Integrals

Integrals of the interpolated curves can also be computed easily.

Note

Integrals for LagrangeInterpolation, BSplineInterpolation, BSplineApprox, Curvefit will error as there are no simple analytical solutions available. Please use numerical methods instead, such as Integrals.jl.

To compute the integrals from the start of time points provided during interpolation to any point, we can do:

# integral(A, t)
 DataInterpolations.integral(A1, 5.0)
129.64386171415265

If we want to compute integrals between two points, we can do:

# integral(A, t1, t2)
 DataInterpolations.integral(A1, 1.0, 5.0)
114.9694509973317

Again, if the interpolation is defined with extrapolate=true, the integral can be computed beyond the range of the timepoints.

# integral(A, t1, t2)
-DataInterpolations.integral(A2, 200.0, 300.0)
1065.2015077631368
Note

If the times provided in the integral go beyond the range of the time points provided during interpolation, it uses extrapolation methods to compute the values, and hence the integral can be misrepsentative and might not reflect the true nature of the data.

+DataInterpolations.integral(A2, 200.0, 300.0)
1065.2015077631368
Note

If the times provided in the integral go beyond the range of the time points provided during interpolation, it uses extrapolation methods to compute the values, and hence the integral can be misrepsentative and might not reflect the true nature of the data.

diff --git a/dev/manual/index.html b/dev/manual/index.html index 9bf97887..dce049aa 100644 --- a/dev/manual/index.html +++ b/dev/manual/index.html @@ -1,2 +1,2 @@ -Manual · DataInterpolations.jl

Methods

DataInterpolations.LinearInterpolationType
LinearInterpolation(u, t; extrapolate = false)

It is the method of interpolating between the data points using a linear polynomial. For any point, two data points one each side are chosen and connected with a line. Extrapolation extends the last linear polynomial on each side.

Arguments

  • u: data points.
  • t: time points.

Keyword Arguments

  • extrapolate: boolean value to allow extrapolation. Defaults to false.
source
DataInterpolations.QuadraticInterpolationType
QuadraticInterpolation(u, t, mode = :Forward; extrapolate = false)

It is the method of interpolating between the data points using quadratic polynomials. For any point, three data points nearby are taken to fit a quadratic polynomial. Extrapolation extends the last quadratic polynomial on each side.

Arguments

  • u: data points.
  • t: time points.
  • mode: :Forward or :Backward. If :Forward, two data points ahead of the point and one data point behind is taken for interpolation. If :Backward, two data points behind and one ahead is taken for interpolation.

Keyword Arguments

  • extrapolate: boolean value to allow extrapolation. Defaults to false.
source
DataInterpolations.LagrangeInterpolationType
LagrangeInterpolation(u, t, n = length(t) - 1; extrapolate = false)

It is the method of interpolation using Lagrange polynomials of (k-1)th order passing through all the data points where k is the number of data points.

Arguments

  • u: data points.
  • t: time points.
  • n: order of the polynomial. Currently only (k-1)th order where k is the number of data points.

Keyword Arguments

  • extrapolate: boolean value to allow extrapolation. Defaults to false.
source
DataInterpolations.AkimaInterpolationType
AkimaInterpolation(u, t; extrapolate = false)

It is a spline interpolation built from cubic polynomials. It forms a continuously differentiable function. For more details, refer: https://en.wikipedia.org/wiki/Akima_spline. Extrapolation extends the last cubic polynomial on each side.

Arguments

  • u: data points.
  • t: time points.

Keyword Arguments

  • extrapolate: boolean value to allow extrapolation. Defaults to false.
source
DataInterpolations.ConstantInterpolationType
ConstantInterpolation(u, t; dir = :left, extrapolate = false)

It is the method of interpolating using a constant polynomial. For any point, two adjacent data points are found on either side (left and right). The value at that point depends on dir. If it is :left, then the value at the left point is chosen and if it is :right, the value at the right point is chosen. Extrapolation extends the last constant polynomial at the end points on each side.

Arguments

  • u: data points.
  • t: time points.

Keyword Arguments

  • dir: indicates which value should be used for interpolation (:left or :right).
  • extrapolate: boolean value to allow extrapolation. Defaults to false.
source
DataInterpolations.QuadraticSplineType
QuadraticSpline(u, t; extrapolate = false)

It is a spline interpolation using piecewise quadratic polynomials between each pair of data points. Its first derivative is also continuous. Extrapolation extends the last quadratic polynomial on each side.

Arguments

  • u: data points.
  • t: time points.

Keyword Arguments

  • extrapolate: boolean value to allow extrapolation. Defaults to false.
source
DataInterpolations.CubicSplineType
QuadraticSpline(u, t; extrapolate = false)

It is a spline interpolation using piecewise cubic polynomials between each pair of data points. Its first and second derivative is also continuous. Extrapolation extends the last cubic polynomial on each side.

Arguments

  • u: data points.
  • t: time points.

Keyword Arguments

  • extrapolate: boolean value to allow extrapolation. Defaults to false.
source
DataInterpolations.BSplineInterpolationType
BSplineInterpolation(u, t, d, pVecType, knotVecType; extrapolate = false)

It is a curve defined by the linear combination of n basis functions of degree d where n is the number of data points. For more information, refer https://pages.mtu.edu/~shene/COURSES/cs3621/NOTES/spline/B-spline/bspline-curve.html. Extrapolation is a constant polynomial of the end points on each side.

Arguments

  • u: data points.
  • t: time points.
  • d: degree of the piecewise polynomial.
  • pVecType: symbol to parameters vector, :Uniform for uniform spaced parameters and :ArcLen for parameters generated by chord length method.
  • knotVecType: symbol to knot vector, :Uniform for uniform knot vector, :Average for average spaced knot vector.

Keyword Arguments

  • extrapolate: boolean value to allow extrapolation. Defaults to false.
source
DataInterpolations.BSplineApproxType
BSplineApprox(u, t, d, h, pVecType, knotVecType; extrapolate = false)

It is a regression based B-spline. The argument choices are the same as the BSplineInterpolation, with the additional parameter h < length(t) which is the number of control points to use, with smaller h indicating more smoothing. For more information, refer http://www.cad.zju.edu.cn/home/zhx/GM/009/00-bsia.pdf. Extrapolation is a constant polynomial of the end points on each side.

Arguments

  • u: data points.
  • t: time points.
  • d: degree of the piecewise polynomial.
  • h: number of control points to use.
  • pVecType: symbol to parameters vector, :Uniform for uniform spaced parameters and :ArcLen for parameters generated by chord length method.
  • knotVecType: symbol to knot vector, :Uniform for uniform knot vector, :Average for average spaced knot vector.

Keyword Arguments

  • extrapolate: boolean value to allow extrapolation. Defaults to false.
source

Utility Functions

DataInterpolations.bracketstrictlymontonicFunction
bracketstrictlymontonic(v, x, guess; lt=<comparison>, by=<transform>, rev=false)

Starting from an initial guess index, find indices (lo, hi) such that v[lo] ≤ x ≤ v[hi] according to the specified order, assuming that x is actually within the range of values found in v. If x is outside that range, either lo will be firstindex(v) or hi will be lastindex(v).

Note that the results will not typically satisfy lo ≤ guess ≤ hi. If x is precisely equal to a value that is not unique in the input v, there is no guarantee that (lo, hi) will encompass all indices corresponding to that value.

This algorithm is essentially an expanding binary search, which can be used as a precursor to searchsorted and related functions, which can take lo and hi as arguments. The purpose of using this function first would be to accelerate convergence in those functions by using correlated guesses for repeated calls. The best guess for the next call of this function would be the index returned by the previous call to searchsorted.

See sort! for an explanation of the keyword arguments by, lt and rev.

source
+Manual · DataInterpolations.jl

Methods

DataInterpolations.LinearInterpolationType
LinearInterpolation(u, t; extrapolate = false)

It is the method of interpolating between the data points using a linear polynomial. For any point, two data points one each side are chosen and connected with a line. Extrapolation extends the last linear polynomial on each side.

Arguments

  • u: data points.
  • t: time points.

Keyword Arguments

  • extrapolate: boolean value to allow extrapolation. Defaults to false.
source
DataInterpolations.QuadraticInterpolationType
QuadraticInterpolation(u, t, mode = :Forward; extrapolate = false)

It is the method of interpolating between the data points using quadratic polynomials. For any point, three data points nearby are taken to fit a quadratic polynomial. Extrapolation extends the last quadratic polynomial on each side.

Arguments

  • u: data points.
  • t: time points.
  • mode: :Forward or :Backward. If :Forward, two data points ahead of the point and one data point behind is taken for interpolation. If :Backward, two data points behind and one ahead is taken for interpolation.

Keyword Arguments

  • extrapolate: boolean value to allow extrapolation. Defaults to false.
source
DataInterpolations.LagrangeInterpolationType
LagrangeInterpolation(u, t, n = length(t) - 1; extrapolate = false)

It is the method of interpolation using Lagrange polynomials of (k-1)th order passing through all the data points where k is the number of data points.

Arguments

  • u: data points.
  • t: time points.
  • n: order of the polynomial. Currently only (k-1)th order where k is the number of data points.

Keyword Arguments

  • extrapolate: boolean value to allow extrapolation. Defaults to false.
source
DataInterpolations.AkimaInterpolationType
AkimaInterpolation(u, t; extrapolate = false)

It is a spline interpolation built from cubic polynomials. It forms a continuously differentiable function. For more details, refer: https://en.wikipedia.org/wiki/Akima_spline. Extrapolation extends the last cubic polynomial on each side.

Arguments

  • u: data points.
  • t: time points.

Keyword Arguments

  • extrapolate: boolean value to allow extrapolation. Defaults to false.
source
DataInterpolations.ConstantInterpolationType
ConstantInterpolation(u, t; dir = :left, extrapolate = false)

It is the method of interpolating using a constant polynomial. For any point, two adjacent data points are found on either side (left and right). The value at that point depends on dir. If it is :left, then the value at the left point is chosen and if it is :right, the value at the right point is chosen. Extrapolation extends the last constant polynomial at the end points on each side.

Arguments

  • u: data points.
  • t: time points.

Keyword Arguments

  • dir: indicates which value should be used for interpolation (:left or :right).
  • extrapolate: boolean value to allow extrapolation. Defaults to false.
source
DataInterpolations.QuadraticSplineType
QuadraticSpline(u, t; extrapolate = false)

It is a spline interpolation using piecewise quadratic polynomials between each pair of data points. Its first derivative is also continuous. Extrapolation extends the last quadratic polynomial on each side.

Arguments

  • u: data points.
  • t: time points.

Keyword Arguments

  • extrapolate: boolean value to allow extrapolation. Defaults to false.
source
DataInterpolations.CubicSplineType
QuadraticSpline(u, t; extrapolate = false)

It is a spline interpolation using piecewise cubic polynomials between each pair of data points. Its first and second derivative is also continuous. Extrapolation extends the last cubic polynomial on each side.

Arguments

  • u: data points.
  • t: time points.

Keyword Arguments

  • extrapolate: boolean value to allow extrapolation. Defaults to false.
source
DataInterpolations.BSplineInterpolationType
BSplineInterpolation(u, t, d, pVecType, knotVecType; extrapolate = false)

It is a curve defined by the linear combination of n basis functions of degree d where n is the number of data points. For more information, refer https://pages.mtu.edu/~shene/COURSES/cs3621/NOTES/spline/B-spline/bspline-curve.html. Extrapolation is a constant polynomial of the end points on each side.

Arguments

  • u: data points.
  • t: time points.
  • d: degree of the piecewise polynomial.
  • pVecType: symbol to parameters vector, :Uniform for uniform spaced parameters and :ArcLen for parameters generated by chord length method.
  • knotVecType: symbol to knot vector, :Uniform for uniform knot vector, :Average for average spaced knot vector.

Keyword Arguments

  • extrapolate: boolean value to allow extrapolation. Defaults to false.
source
DataInterpolations.BSplineApproxType
BSplineApprox(u, t, d, h, pVecType, knotVecType; extrapolate = false)

It is a regression based B-spline. The argument choices are the same as the BSplineInterpolation, with the additional parameter h < length(t) which is the number of control points to use, with smaller h indicating more smoothing. For more information, refer http://www.cad.zju.edu.cn/home/zhx/GM/009/00-bsia.pdf. Extrapolation is a constant polynomial of the end points on each side.

Arguments

  • u: data points.
  • t: time points.
  • d: degree of the piecewise polynomial.
  • h: number of control points to use.
  • pVecType: symbol to parameters vector, :Uniform for uniform spaced parameters and :ArcLen for parameters generated by chord length method.
  • knotVecType: symbol to knot vector, :Uniform for uniform knot vector, :Average for average spaced knot vector.

Keyword Arguments

  • extrapolate: boolean value to allow extrapolation. Defaults to false.
source

Utility Functions

DataInterpolations.bracketstrictlymontonicFunction
bracketstrictlymontonic(v, x, guess; lt=<comparison>, by=<transform>, rev=false)

Starting from an initial guess index, find indices (lo, hi) such that v[lo] ≤ x ≤ v[hi] according to the specified order, assuming that x is actually within the range of values found in v. If x is outside that range, either lo will be firstindex(v) or hi will be lastindex(v).

Note that the results will not typically satisfy lo ≤ guess ≤ hi. If x is precisely equal to a value that is not unique in the input v, there is no guarantee that (lo, hi) will encompass all indices corresponding to that value.

This algorithm is essentially an expanding binary search, which can be used as a precursor to searchsorted and related functions, which can take lo and hi as arguments. The purpose of using this function first would be to accelerate convergence in those functions by using correlated guesses for repeated calls. The best guess for the next call of this function would be the index returned by the previous call to searchsorted.

See sort! for an explanation of the keyword arguments by, lt and rev.

source
diff --git a/dev/methods/ecdc046b.svg b/dev/methods/1748e559.svg similarity index 97% rename from dev/methods/ecdc046b.svg rename to dev/methods/1748e559.svg index 01f0cb12..738ef0d3 100644 --- a/dev/methods/ecdc046b.svg +++ b/dev/methods/1748e559.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/e15a5ffe.svg b/dev/methods/35f70a00.svg similarity index 97% rename from dev/methods/e15a5ffe.svg rename to dev/methods/35f70a00.svg index e7481c57..54f10bdf 100644 --- a/dev/methods/e15a5ffe.svg +++ b/dev/methods/35f70a00.svg @@ -1,57 +1,57 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/f8c8ddad.svg b/dev/methods/475d8590.svg similarity index 95% rename from dev/methods/f8c8ddad.svg rename to dev/methods/475d8590.svg index 1d007b99..59b4d677 100644 --- a/dev/methods/f8c8ddad.svg +++ b/dev/methods/475d8590.svg @@ -1,145 +1,145 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/e3964b5c.svg b/dev/methods/5511d890.svg similarity index 97% rename from dev/methods/e3964b5c.svg rename to dev/methods/5511d890.svg index c89c7f5d..fa5e9b9d 100644 --- a/dev/methods/e3964b5c.svg +++ b/dev/methods/5511d890.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/ad4f683d.svg b/dev/methods/6db1f463.svg similarity index 97% rename from dev/methods/ad4f683d.svg rename to dev/methods/6db1f463.svg index 301468b7..b7cc20fc 100644 --- a/dev/methods/ad4f683d.svg +++ b/dev/methods/6db1f463.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/9ad2672e.svg b/dev/methods/803808eb.svg similarity index 97% rename from dev/methods/9ad2672e.svg rename to dev/methods/803808eb.svg index fe683660..5973d4a3 100644 --- a/dev/methods/9ad2672e.svg +++ b/dev/methods/803808eb.svg @@ -1,57 +1,57 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/4dc6053f.svg b/dev/methods/98e50314.svg similarity index 97% rename from dev/methods/4dc6053f.svg rename to dev/methods/98e50314.svg index 3e620ac4..d6aa7185 100644 --- a/dev/methods/4dc6053f.svg +++ b/dev/methods/98e50314.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/af6f43a5.svg b/dev/methods/aec0f391.svg similarity index 86% rename from dev/methods/af6f43a5.svg rename to dev/methods/aec0f391.svg index df84df1f..d4fb1fdf 100644 --- a/dev/methods/af6f43a5.svg +++ b/dev/methods/aec0f391.svg @@ -1,62 +1,62 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/3335ea81.svg b/dev/methods/b5d5784a.svg similarity index 95% rename from dev/methods/3335ea81.svg rename to dev/methods/b5d5784a.svg index 22c0a955..68542dd4 100644 --- a/dev/methods/3335ea81.svg +++ b/dev/methods/b5d5784a.svg @@ -1,145 +1,145 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/61d3525c.svg b/dev/methods/b8a5ae51.svg similarity index 80% rename from dev/methods/61d3525c.svg rename to dev/methods/b8a5ae51.svg index adc69de1..9476afb5 100644 --- a/dev/methods/61d3525c.svg +++ b/dev/methods/b8a5ae51.svg @@ -1,248 +1,248 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/661d1020.svg b/dev/methods/f32dc54c.svg similarity index 97% rename from dev/methods/661d1020.svg rename to dev/methods/f32dc54c.svg index 9a08741d..b630d40d 100644 --- a/dev/methods/661d1020.svg +++ b/dev/methods/f32dc54c.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/c2fb34ca.svg b/dev/methods/f7401cdf.svg similarity index 97% rename from dev/methods/c2fb34ca.svg rename to dev/methods/f7401cdf.svg index d87a48ab..f19d15e5 100644 --- a/dev/methods/c2fb34ca.svg +++ b/dev/methods/f7401cdf.svg @@ -1,59 +1,59 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/c4fce43a.svg b/dev/methods/f98894b4.svg similarity index 97% rename from dev/methods/c4fce43a.svg rename to dev/methods/f98894b4.svg index b36d81a2..f2282ddf 100644 --- a/dev/methods/c4fce43a.svg +++ b/dev/methods/f98894b4.svg @@ -1,53 +1,53 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/index.html b/dev/methods/index.html index f4d52530..fb0e3561 100644 --- a/dev/methods/index.html +++ b/dev/methods/index.html @@ -13,24 +13,24 @@ 205.8 252.3

For each method, we will show how to perform the fit and use the plot recipe to show the fitting curve.

Linear Interpolation

This is a linear interpolation between the ends points of the interval of input data points.

A = LinearInterpolation(u, t)
 scatter(t, u, label = "input data")
-plot!(A)
Example block output

Quadratic Interpolation

This function fits a parabola passing through the two nearest points from the input data point as well as the next-closest point on the right or left, depending on whether the forward- or backward-looking mode is selected (default mode is forward-looking). It is continuous and piecewise differentiable.

A = QuadraticInterpolation(u, t) # same as QuadraticInterpolation(u,t,:Forward)
+plot!(A)
Example block output

Quadratic Interpolation

This function fits a parabola passing through the two nearest points from the input data point as well as the next-closest point on the right or left, depending on whether the forward- or backward-looking mode is selected (default mode is forward-looking). It is continuous and piecewise differentiable.

A = QuadraticInterpolation(u, t) # same as QuadraticInterpolation(u,t,:Forward)
 # alternatively: A = QuadraticInterpolation(u,t,:Backward)
 scatter(t, u, label = "input data")
-plot!(A)
Example block output

Lagrange Interpolation

It fits a polynomial of degree d (=length(t)-1), and is thus a continuously differentiable function.

A = LagrangeInterpolation(u, t)
+plot!(A)
Example block output

Lagrange Interpolation

It fits a polynomial of degree d (=length(t)-1), and is thus a continuously differentiable function.

A = LagrangeInterpolation(u, t)
 scatter(t, u, label = "input data")
-plot!(A)
Example block output

Constant Interpolation

This function is constant between data points. By default, it takes the value at the left end of the interval. One can change that behavior by passing the keyword argument dir = :right.

A = ConstantInterpolation(u, t)
+plot!(A)
Example block output

Constant Interpolation

This function is constant between data points. By default, it takes the value at the left end of the interval. One can change that behavior by passing the keyword argument dir = :right.

A = ConstantInterpolation(u, t)
 scatter(t, u, label = "input data")
-plot!(A)
Example block output

Or using the right endpoints:

A = ConstantInterpolation(u, t, dir = :right)
+plot!(A)
Example block output

Or using the right endpoints:

A = ConstantInterpolation(u, t, dir = :right)
 scatter(t, u, label = "input data")
-plot!(A)
Example block output

Quadratic Spline

This is the quadratic spline. It is a continuously differentiable interpolation which hits each of the data points exactly. Splines are a local interpolation method, meaning that the curve in a given spot is only affected by the points nearest to it.

A = QuadraticSpline(u, t)
+plot!(A)
Example block output

Quadratic Spline

This is the quadratic spline. It is a continuously differentiable interpolation which hits each of the data points exactly. Splines are a local interpolation method, meaning that the curve in a given spot is only affected by the points nearest to it.

A = QuadraticSpline(u, t)
 scatter(t, u, label = "input data")
-plot!(A)
Example block output

Cubic Spline

This is the cubic spline. It is a continuously twice differentiable interpolation which hits each of the data points exactly.

A = CubicSpline(u, t)
+plot!(A)
Example block output

Cubic Spline

This is the cubic spline. It is a continuously twice differentiable interpolation which hits each of the data points exactly.

A = CubicSpline(u, t)
 scatter(t, u, label = "input data")
-plot!(A)
Example block output

B-Splines

This is an interpolating B-spline. B-splines are a global method, meaning that every data point is taken into account for each point of the curve. The interpolating B-spline is the version which hits each of the points. This method is described in more detail here. Let's plot a cubic B-spline (3rd order). Since the data points are not close to uniformly spaced, we will use the :ArcLen and :Average choices:

A = BSplineInterpolation(u, t, 3, :ArcLen, :Average)
+plot!(A)
Example block output

B-Splines

This is an interpolating B-spline. B-splines are a global method, meaning that every data point is taken into account for each point of the curve. The interpolating B-spline is the version which hits each of the points. This method is described in more detail here. Let's plot a cubic B-spline (3rd order). Since the data points are not close to uniformly spaced, we will use the :ArcLen and :Average choices:

A = BSplineInterpolation(u, t, 3, :ArcLen, :Average)
 scatter(t, u, label = "input data")
-plot!(A)
Example block output

The approximating B-spline is a smoothed version of the B-spline. It again is a global method. In this case, we need to give a number of control points length(t)>h and this method fits a B-spline through the control points which is a least square approximation. This has a natural effect of smoothing the data. For example, if we use 4 control points, we get the result:

A = BSplineApprox(u, t, 3, 4, :ArcLen, :Average)
+plot!(A)
Example block output

The approximating B-spline is a smoothed version of the B-spline. It again is a global method. In this case, we need to give a number of control points length(t)>h and this method fits a B-spline through the control points which is a least square approximation. This has a natural effect of smoothing the data. For example, if we use 4 control points, we get the result:

A = BSplineApprox(u, t, 3, 4, :ArcLen, :Average)
 scatter(t, u, label = "input data")
-plot!(A)
Example block output

Regularization Smoothing

Smoothing by regularization (a.k.a. ridge regression) finds a function $\hat{u}$ that minimizes the objective function:

$Q(\hat{u}) = \int_{t_1}^{t_N} |\hat{u}(t) - u(t)|^2 \mathrm{d}t + \lambda \int_{\hat{t}_1}^{\hat{t}_N} |\hat{u}^{(d)}(\hat{t})|^2 \mathrm{d} \hat{t}$

where $(d)$ denotes derivative order and $\lambda$ is the regularization (smoothing) parameter. The integrals are evaluated numerically at the set of $t$ values for the first term and $\hat{t}$ values for the second term (equal to $t$ if not provided). Regularization smoothing is a global method that creates a smooth curve directly. See Stickel (2010) Comput. Chem. Eng. 34:467 for details. The implementation in this package uses cubic splines to interpolate between the smoothed points after they are determined.

using RegularizationTools
+plot!(A)
Example block output

Regularization Smoothing

Smoothing by regularization (a.k.a. ridge regression) finds a function $\hat{u}$ that minimizes the objective function:

$Q(\hat{u}) = \int_{t_1}^{t_N} |\hat{u}(t) - u(t)|^2 \mathrm{d}t + \lambda \int_{\hat{t}_1}^{\hat{t}_N} |\hat{u}^{(d)}(\hat{t})|^2 \mathrm{d} \hat{t}$

where $(d)$ denotes derivative order and $\lambda$ is the regularization (smoothing) parameter. The integrals are evaluated numerically at the set of $t$ values for the first term and $\hat{t}$ values for the second term (equal to $t$ if not provided). Regularization smoothing is a global method that creates a smooth curve directly. See Stickel (2010) Comput. Chem. Eng. 34:467 for details. The implementation in this package uses cubic splines to interpolate between the smoothed points after they are determined.

using RegularizationTools
 d = 2
 λ = 1e3
 A = RegularizationSmooth(u, t, d; λ = λ, alg = :fixed)
@@ -42,7 +42,7 @@
 lw = 1.5
 scatter(t, u, label = "data")
 scatter!(t, û, marker = :square, label = "smoothed data")
-plot!(titp, uitp, lw = lw, label = "smoothed interpolation")
Example block output

Dense Data Demonstration

Some methods are better suited for dense data. Let's generate such data to demonstrate these methods.

import StableRNGs: StableRNG
+plot!(titp, uitp, lw = lw, label = "smoothed interpolation")
Example block output

Dense Data Demonstration

Some methods are better suited for dense data. Let's generate such data to demonstrate these methods.

import StableRNGs: StableRNG
 rng = StableRNG(318)
 t = sort(10 .* rand(rng, 100))
 u = sin.(t) .+ 0.5 * randn(rng, 100);
100-element Vector{Float64}:
@@ -76,17 +76,17 @@
 scatter(t, u, label = "simulated data", legend = :top)
 scatter!(t, û, marker = (:square, 4), label = "smoothed data")
 plot!(titp, uitp, lw = lw, label = "smoothed interpolation")
-plot!(titp, ûm, lw = lw, linestyle = :dash, label = "smoothed, more points")
Example block output

Curve Fits

A curve fit works with both dense and sparse data. We will demonstrate the curve fit on the dense data since we generated it based on sin(t), so this is the curve we want to fit through it. To do so, let's define a similar function with parameters. Let's choose the form:

m(t, p) = @. p[1] * sin(p[2] * t) + p[3] * cos(p[4] * t)
m (generic function with 1 method)

Notice that this is a function on the whole array of t and expects an array for the predicted u out. This choice of m is based on the assumption that our function is of the form p1*sin(p2*t)+p3*cos(p4*t). We want to find the p to match our data. Let's start with the guess of every p being zero, that is p=ones(4). Then we would fit this curve using:

using Optim
+plot!(titp, ûm, lw = lw, linestyle = :dash, label = "smoothed, more points")
Example block output

Curve Fits

A curve fit works with both dense and sparse data. We will demonstrate the curve fit on the dense data since we generated it based on sin(t), so this is the curve we want to fit through it. To do so, let's define a similar function with parameters. Let's choose the form:

m(t, p) = @. p[1] * sin(p[2] * t) + p[3] * cos(p[4] * t)
m (generic function with 1 method)

Notice that this is a function on the whole array of t and expects an array for the predicted u out. This choice of m is based on the assumption that our function is of the form p1*sin(p2*t)+p3*cos(p4*t). We want to find the p to match our data. Let's start with the guess of every p being zero, that is p=ones(4). Then we would fit this curve using:

using Optim
 A = Curvefit(u, t, m, ones(4), LBFGS())
 scatter(t, u, label = "points", legend = :bottomright)
-plot!(A)
Example block output

We can check what the fitted parameters are via:

A.pmin
4-element Vector{Float64}:
+plot!(A)
Example block output

We can check what the fitted parameters are via:

A.pmin
4-element Vector{Float64}:
   1.00251731850411
   1.0396588440319725
  -0.13178842465264956
   1.0670107400675999

Notice that it essentially made p3=0 with p1=p2=1, meaning it approximately found sin(t)! But note that the ability to fit is dependent on the initial parameters. For example, with p=zeros(4) as the initial parameters, the fit is not good:

A = Curvefit(u, t, m, zeros(4), LBFGS())
 scatter(t, u, label = "points", legend = :bottomright)
-plot!(A)
Example block output

And the parameters show the issue:

A.pmin
4-element Vector{Float64}:
+plot!(A)
Example block output

And the parameters show the issue:

A.pmin
4-element Vector{Float64}:
  0.0
  0.0
  0.042632088464589324
- 0.0
+ 0.0