diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index 0cb3b4cd..754d8dc6 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.10.1","generation_timestamp":"2024-02-22T16:22:06","documenter_version":"1.2.1"}} \ No newline at end of file +{"documenter":{"julia_version":"1.10.1","generation_timestamp":"2024-02-25T20:52:13","documenter_version":"1.2.1"}} \ No newline at end of file diff --git a/dev/assets/Manifest.toml b/dev/assets/Manifest.toml index b3175e19..c072dd4b 100644 --- a/dev/assets/Manifest.toml +++ b/dev/assets/Manifest.toml @@ -135,9 +135,9 @@ version = "0.3.0" [[deps.Compat]] deps = ["TOML", "UUIDs"] -git-tree-sha1 = "d2c021fbdde94f6cdaa799639adfeeaa17fd67f5" +git-tree-sha1 = "c955881e3c981181362ae4088b35995446298b80" uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" -version = "4.13.0" +version = "4.14.0" weakdeps = ["Dates", "LinearAlgebra"] [deps.Compat.extensions] @@ -399,9 +399,9 @@ version = "1.3.0" [[deps.Git_jll]] deps = ["Artifacts", "Expat_jll", "JLLWrappers", "LibCURL_jll", "Libdl", "Libiconv_jll", "OpenSSL_jll", "PCRE2_jll", "Zlib_jll"] -git-tree-sha1 = "b30c473c97fcc1e1e44fab8f3e88fd1b89c9e9d1" +git-tree-sha1 = "99f27817475017260f1ff24c771a5efef5765e34" uuid = "f8c6e375-362e-5223-8a59-34ff63f689eb" -version = "2.43.0+0" +version = "2.44.0+0" [[deps.Glib_jll]] deps = ["Artifacts", "Gettext_jll", "JLLWrappers", "Libdl", "Libffi_jll", "Libiconv_jll", "Libmount_jll", "PCRE2_jll", "Zlib_jll"] @@ -472,9 +472,9 @@ version = "0.21.4" [[deps.JpegTurbo_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl"] -git-tree-sha1 = "60b1194df0a3298f460063de985eae7b01bc011a" +git-tree-sha1 = "3336abae9a713d2210bb57ab484b1e065edd7d23" uuid = "aacddb02-875f-59d6-b918-886e6ef4fbf8" -version = "3.0.1+0" +version = "3.0.2+0" [[deps.LAME_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] @@ -1158,9 +1158,9 @@ version = "1.1.34+0" [[deps.XZ_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl"] -git-tree-sha1 = "ac88fb95ae6447c8dda6a5503f3bafd496ae8632" +git-tree-sha1 = "37195dcb94a5970397ad425b95a9a26d0befce3a" uuid = "ffd25f8a-64ca-5728-b0f7-c24cf3aae800" -version = "5.4.6+0" +version = "5.6.0+0" [[deps.Xorg_libICE_jll]] deps = ["Libdl", "Pkg"] diff --git a/dev/index.html b/dev/index.html index a4dcc9db..6b455127 100644 --- a/dev/index.html +++ b/dev/index.html @@ -31,7 +31,7 @@ [c3611d14] ColorVectorSpace v0.10.0 [5ae59095] Colors v0.12.10 [bbf7d656] CommonSubexpressions v0.3.0 - [34da2185] Compat v4.13.0 + [34da2185] Compat v4.14.0 [f0e56b4a] ConcurrentUtilities v2.3.1 [187b0558] ConstructionBase v1.5.4 [d38c429a] Contour v0.6.2 @@ -134,11 +134,11 @@ [0656b61e] GLFW_jll v3.3.9+0 [d2c73de3] GR_jll v0.73.2+0 [78b55507] Gettext_jll v0.21.0+0 - [f8c6e375] Git_jll v2.43.0+0 + [f8c6e375] Git_jll v2.44.0+0 [7746bdde] Glib_jll v2.76.5+0 [3b182d85] Graphite2_jll v1.3.14+0 [2e76f6c2] HarfBuzz_jll v2.8.1+1 - [aacddb02] JpegTurbo_jll v3.0.1+0 + [aacddb02] JpegTurbo_jll v3.0.2+0 [c1c5ebd0] LAME_jll v3.100.1+0 [88015f11] LERC_jll v3.0.0+1 [1d63c593] LLVMOpenMP_jll v15.0.7+0 @@ -162,7 +162,7 @@ [2381bf8a] Wayland_protocols_jll v1.31.0+0 [02c8fc9c] XML2_jll v2.12.2+0 [aed1982a] XSLT_jll v1.1.34+0 - [ffd25f8a] XZ_jll v5.4.6+0 + [ffd25f8a] XZ_jll v5.6.0+0 [f67eecfb] Xorg_libICE_jll v1.0.10+1 [c834827a] Xorg_libSM_jll v1.2.3+0 [4f6342f7] Xorg_libX11_jll v1.8.6+0 @@ -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 5b6f3586..54e4a803 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 4bd7a16e..726b373f 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/2bbd690f.svg b/dev/methods/110bf474.svg similarity index 97% rename from dev/methods/2bbd690f.svg rename to dev/methods/110bf474.svg index 66580bf7..77493a52 100644 --- a/dev/methods/2bbd690f.svg +++ b/dev/methods/110bf474.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/ef986565.svg b/dev/methods/1f1e599f.svg similarity index 95% rename from dev/methods/ef986565.svg rename to dev/methods/1f1e599f.svg index 4bbf5dc2..12e02518 100644 --- a/dev/methods/ef986565.svg +++ b/dev/methods/1f1e599f.svg @@ -1,145 +1,145 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/9443c9be.svg b/dev/methods/26f02551.svg similarity index 97% rename from dev/methods/9443c9be.svg rename to dev/methods/26f02551.svg index cb35f104..02f04423 100644 --- a/dev/methods/9443c9be.svg +++ b/dev/methods/26f02551.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/77eae5bd.svg b/dev/methods/3498931a.svg similarity index 95% rename from dev/methods/77eae5bd.svg rename to dev/methods/3498931a.svg index cae8e546..f7a263f3 100644 --- a/dev/methods/77eae5bd.svg +++ b/dev/methods/3498931a.svg @@ -1,145 +1,145 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/898077a5.svg b/dev/methods/35055978.svg similarity index 97% rename from dev/methods/898077a5.svg rename to dev/methods/35055978.svg index 33af3094..b9a68ed8 100644 --- a/dev/methods/898077a5.svg +++ b/dev/methods/35055978.svg @@ -1,53 +1,53 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/3d8e0264.svg b/dev/methods/3bf96f41.svg similarity index 97% rename from dev/methods/3d8e0264.svg rename to dev/methods/3bf96f41.svg index b238b97f..feee5969 100644 --- a/dev/methods/3d8e0264.svg +++ b/dev/methods/3bf96f41.svg @@ -1,59 +1,59 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/0a51dc2e.svg b/dev/methods/43f8af8c.svg similarity index 97% rename from dev/methods/0a51dc2e.svg rename to dev/methods/43f8af8c.svg index f6f313aa..23e60b1a 100644 --- a/dev/methods/0a51dc2e.svg +++ b/dev/methods/43f8af8c.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/e022d32e.svg b/dev/methods/60c73e3c.svg similarity index 86% rename from dev/methods/e022d32e.svg rename to dev/methods/60c73e3c.svg index 668814ad..83d05b3e 100644 --- a/dev/methods/e022d32e.svg +++ b/dev/methods/60c73e3c.svg @@ -1,62 +1,62 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/11ea6f5e.svg b/dev/methods/6e2c9c33.svg similarity index 97% rename from dev/methods/11ea6f5e.svg rename to dev/methods/6e2c9c33.svg index 5d5e65df..5f10245d 100644 --- a/dev/methods/11ea6f5e.svg +++ b/dev/methods/6e2c9c33.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/c78e078d.svg b/dev/methods/7d713435.svg similarity index 97% rename from dev/methods/c78e078d.svg rename to dev/methods/7d713435.svg index 474a4090..b5490d8e 100644 --- a/dev/methods/c78e078d.svg +++ b/dev/methods/7d713435.svg @@ -1,57 +1,57 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/b1ff253b.svg b/dev/methods/b088b4b5.svg similarity index 80% rename from dev/methods/b1ff253b.svg rename to dev/methods/b088b4b5.svg index 5d950ea7..69126088 100644 --- a/dev/methods/b1ff253b.svg +++ b/dev/methods/b088b4b5.svg @@ -1,248 +1,248 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/361ab88c.svg b/dev/methods/bc52c47f.svg similarity index 97% rename from dev/methods/361ab88c.svg rename to dev/methods/bc52c47f.svg index 92b11919..7a33fbf6 100644 --- a/dev/methods/361ab88c.svg +++ b/dev/methods/bc52c47f.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/f8c34b9d.svg b/dev/methods/d8d65d27.svg similarity index 97% rename from dev/methods/f8c34b9d.svg rename to dev/methods/d8d65d27.svg index 41a751f1..5237ce3e 100644 --- a/dev/methods/f8c34b9d.svg +++ b/dev/methods/d8d65d27.svg @@ -1,57 +1,57 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/index.html b/dev/methods/index.html index 8f7bf605..0e8a1590 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