From 4135f03f1aea1c312a63e5b0aa7b7786500c13c1 Mon Sep 17 00:00:00 2001 From: "Documenter.jl" Date: Sun, 5 Nov 2023 20:14:06 +0000 Subject: [PATCH] build based on e16d610 --- dev/.documenter-siteinfo.json | 2 +- dev/index.html | 30 +- dev/interface/index.html | 2 +- dev/methods/{462123ae.svg => 1c09f9f1.svg} | 262 ++++++------ dev/methods/{dec33a62.svg => 64996f58.svg} | 86 ++-- dev/methods/{f130043a.svg => 6c6ec359.svg} | 262 ++++++------ dev/methods/{6e3c99a2.svg => 6e64260c.svg} | 82 ++-- dev/methods/{20390be5.svg => 761d419e.svg} | 468 ++++++++++----------- dev/methods/{479c6e24.svg => 8a582399.svg} | 82 ++-- dev/methods/{297a1a76.svg => 93e0f272.svg} | 82 ++-- dev/methods/{2022a3c3.svg => a4bc4ae2.svg} | 78 ++-- dev/methods/{ecaa0f5c.svg => ae1a54f0.svg} | 96 ++--- dev/methods/{fed69fb6.svg => dd3f52cf.svg} | 82 ++-- dev/methods/{2f6a74f8.svg => f5a84139.svg} | 86 ++-- dev/methods/{6106d6b1.svg => f74be8f3.svg} | 90 ++-- dev/methods/{9f2ee4db.svg => ffaf03f7.svg} | 82 ++-- dev/methods/index.html | 36 +- 17 files changed, 954 insertions(+), 954 deletions(-) rename dev/methods/{462123ae.svg => 1c09f9f1.svg} (95%) rename dev/methods/{dec33a62.svg => 64996f58.svg} (97%) rename dev/methods/{f130043a.svg => 6c6ec359.svg} (95%) rename dev/methods/{6e3c99a2.svg => 6e64260c.svg} (97%) rename dev/methods/{20390be5.svg => 761d419e.svg} (80%) rename dev/methods/{479c6e24.svg => 8a582399.svg} (97%) rename dev/methods/{297a1a76.svg => 93e0f272.svg} (97%) rename dev/methods/{2022a3c3.svg => a4bc4ae2.svg} (97%) rename dev/methods/{ecaa0f5c.svg => ae1a54f0.svg} (86%) rename dev/methods/{fed69fb6.svg => dd3f52cf.svg} (97%) rename dev/methods/{2f6a74f8.svg => f5a84139.svg} (97%) rename dev/methods/{6106d6b1.svg => f74be8f3.svg} (97%) rename dev/methods/{9f2ee4db.svg => ffaf03f7.svg} (97%) diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index 6f59ad4c..b45e4666 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.9.3","generation_timestamp":"2023-10-22T16:40:15","documenter_version":"1.1.1"}} \ No newline at end of file +{"documenter":{"julia_version":"1.9.3","generation_timestamp":"2023-11-05T20:14:01","documenter_version":"1.1.2"}} \ No newline at end of file diff --git a/dev/index.html b/dev/index.html index 61035a35..31e11cd8 100644 --- a/dev/index.html +++ b/dev/index.html @@ -2,7 +2,7 @@ DataInterpolations.jl · DataInterpolations.jl

DataInterpolations.jl

DataInterpolations.jl is a library for performing interpolations of one-dimensional data. By "data interpolations" we mean techniques for interpolating possibly noisy data, and thus some methods are mixtures of regressions with interpolations (i.e. do not hit the data points exactly, smoothing out the lines). This library can be used to fill in intermediate data points in applications like timeseries data.

Installation

To install DataInterpolations.jl, use the Julia package manager:

using Pkg
 Pkg.add("DataInterpolations")

Available Interpolations

In all cases, u an AbstractVector of values and t is an AbstractVector of timepoints corresponding to (u,t) pairs.

  • ConstantInterpolation(u,t) - A piecewise constant interpolation.

  • LinearInterpolation(u,t) - A linear interpolation.

  • QuadraticInterpolation(u,t) - A quadratic interpolation.

  • LagrangeInterpolation(u,t,n) - A Lagrange interpolation of order n.

  • QuadraticSpline(u,t) - A quadratic spline interpolation.

  • CubicSpline(u,t) - A cubic spline interpolation.

  • AkimaInterpolation(u, t) - Akima spline interpolation provides a smoothing effect and is computationally efficient.

  • BSplineInterpolation(u,t,d,pVec,knotVec) - An interpolation B-spline. This is a B-spline which hits each of the data points. The argument choices are:

    • d - degree of B-spline
    • pVec - Symbol to Parameters Vector, pVec = :Uniform for uniform spaced parameters and pVec = :ArcLen for parameters generated by chord length method.
    • knotVec - Symbol to Knot Vector, knotVec = :Uniform for uniform knot vector, knotVec = :Average for average spaced knot vector.
  • BSplineApprox(u,t,d,h,pVec,knotVec) - A regression B-spline which smooths the fitting curve. 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.

Extension Methods

The follow methods require extra dependencies and will be loaded as package extensions.

  • Curvefit(u,t,m,p,alg) - An interpolation which is done by fitting a user-given functional form m(t,p) where p is the vector of parameters. The user's input p is a an initial value for a least-square fitting, alg is the algorithm choice to use for optimize the cost function (sum of squared deviations) via Optim.jl and optimal ps are used in the interpolation. Requires using Optim.
  • RegularizationSmooth(u,t,d;λ,alg) - A regularization algorithm (ridge regression) which is done by minimizing an objective function (l2 loss + derivatives of order d) integrated in the time span. It is a global method and creates a smooth curve. Requires using RegularizationTools.

Plotting

DataInterpolations.jl is tied into the Plots.jl ecosystem, by way of RecipesBase. Any interpolation can be plotted using the plot command (or any other), since they have type recipes associated with them.

For convenience, and to allow keyword arguments to propagate properly, DataInterpolations.jl also defines several series types, corresponding to different interpolations.

The series types defined are:

  • :linear_interp
  • :quadratic_interp
  • :lagrange_interp
  • :quadratic_spline
  • :cubic_spline

By and large, these accept the same keywords as their function counterparts.

Contributing

Reproducibility

The documentation of this SciML package was built using these direct dependencies,
Status `~/work/DataInterpolations.jl/DataInterpolations.jl/docs/Project.toml`
   [82cc6244] DataInterpolations v4.4.0 `~/work/DataInterpolations.jl/DataInterpolations.jl`
-  [e30172f5] Documenter v1.1.1
+  [e30172f5] Documenter v1.1.2
   [429524aa] Optim v1.7.8
   [91a5bcdd] Plots v1.39.0
   [29dad682] RegularizationTools v0.6.0
@@ -12,15 +12,15 @@
   Official https://julialang.org/ release
 Platform Info:
   OS: Linux (x86_64-linux-gnu)
-  CPU: 2 × Intel(R) Xeon(R) Platinum 8272CL CPU @ 2.60GHz
+  CPU: 4 × AMD EPYC 7763 64-Core Processor
   WORD_SIZE: 64
   LIBM: libopenlibm
-  LLVM: libLLVM-14.0.6 (ORCJIT, skylake-avx512)
-  Threads: 1 on 2 virtual cores
A more complete overview of all dependencies and their versions is also provided.
Status `~/work/DataInterpolations.jl/DataInterpolations.jl/docs/Manifest.toml`
+  LLVM: libLLVM-14.0.6 (ORCJIT, znver3)
+  Threads: 1 on 4 virtual cores
A more complete overview of all dependencies and their versions is also provided.
Status `~/work/DataInterpolations.jl/DataInterpolations.jl/docs/Manifest.toml`
   [a4c015fc] ANSIColoredPrinters v0.0.1
   [1520ce14] AbstractTrees v0.4.4
-  [79e6a3ab] Adapt v3.6.2
-  [4fba245c] ArrayInterface v7.4.11
+  [79e6a3ab] Adapt v3.7.1
+  [4fba245c] ArrayInterface v7.5.1
   [d1d4a3ce] BitFlags v0.1.7
   [49dc2e85] Calculus v0.5.1
   [944b1d66] CodecZlib v0.7.3
@@ -30,7 +30,7 @@
   [5ae59095] Colors v0.12.10
   [bbf7d656] CommonSubexpressions v0.3.0
   [34da2185] Compat v4.10.0
-  [f0e56b4a] ConcurrentUtilities v2.2.1
+  [f0e56b4a] ConcurrentUtilities v2.3.0
   [187b0558] ConstructionBase v1.5.4
   [d38c429a] Contour v0.6.2
   [a8cc5b0e] Crayons v4.1.1
@@ -42,7 +42,7 @@
   [163ba53b] DiffResults v1.1.0
   [b552c78f] DiffRules v1.15.1
   [ffbed154] DocStringExtensions v0.9.3
-  [e30172f5] Documenter v1.1.1
+  [e30172f5] Documenter v1.1.2
   [460bff9d] ExceptionUnwrapping v0.1.9
   [c87230d0] FFMPEG v0.4.1
   [1a297f60] FillArrays v1.7.0
@@ -60,7 +60,7 @@
   [1019f520] JLFzf v0.1.6
   [692b3bcd] JLLWrappers v1.5.0
   [682c06a0] JSON v0.21.4
-  [b964fa9f] LaTeXStrings v1.3.0
+  [b964fa9f] LaTeXStrings v1.3.1
   [23fbe1c1] Latexify v0.16.1
   [0e77f7df] LazilyInitializedFields v1.2.1
   [50d2b5c4] Lazy v0.15.1
@@ -98,7 +98,7 @@
   [29dad682] RegularizationTools v0.6.0
   [05181044] RelocatableFolders v1.0.1
   [ae029012] Requires v1.3.0
-  [6c6a2e73] Scratch v1.2.0
+  [6c6a2e73] Scratch v1.2.1
   [efcf1570] Setfield v1.1.1
   [992d4aef] Showoff v1.0.3
   [777ac1f9] SimpleBufferStream v1.1.0
@@ -113,7 +113,7 @@
   [3783bdb8] TableTraits v1.0.1
   [bd369af6] Tables v1.11.1
   [62fd8b95] TensorCore v0.1.1
-  [3bb67fe8] TranscodingStreams v0.10.1
+  [3bb67fe8] TranscodingStreams v0.10.2
   [5c2747f8] URIs v1.5.1
   [3a884ed6] UnPack v1.0.2
   [d9a01c3f] Underscores v3.0.0
@@ -125,7 +125,7 @@
   [83423d85] Cairo_jll v1.16.1+1
   [2702e6a9] EpollShim_jll v0.0.20230411+0
   [2e619515] Expat_jll v2.5.0+0
-⌃ [b22a6f82] FFMPEG_jll v4.4.2+2
+  [b22a6f82] FFMPEG_jll v4.4.4+1
   [a3f928ae] Fontconfig_jll v2.13.93+0
   [d7e528f0] FreeType2_jll v2.13.1+0
   [559328eb] FriBidi_jll v1.0.10+0
@@ -149,11 +149,11 @@
   [89763e89] Libtiff_jll v4.5.1+1
   [38a345b3] Libuuid_jll v2.36.0+0
   [e7412a2a] Ogg_jll v1.3.5+1
-⌅ [458c3c95] OpenSSL_jll v1.1.23+0
+  [458c3c95] OpenSSL_jll v3.0.12+0
   [efe28fd5] OpenSpecFun_jll v0.5.5+0
   [91d4177d] Opus_jll v1.3.2+0
   [30392449] Pixman_jll v0.42.2+0
-  [c0090381] Qt6Base_jll v6.5.2+2
+  [c0090381] Qt6Base_jll v6.5.3+0
   [a44049a8] Vulkan_Loader_jll v1.3.243+0
   [a2964d1f] Wayland_jll v1.21.0+1
   [2381bf8a] Wayland_protocols_jll v1.25.0+0
@@ -244,4 +244,4 @@
   [8e850b90] libblastrampoline_jll v5.8.0+0
   [8e850ede] nghttp2_jll v1.48.0+0
   [3f19e933] p7zip_jll v17.4.0+0
-Info Packages marked with ⌃ and ⌅ have new versions available, but those with ⌅ are restricted by compatibility constraints 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 10572245..22208021 100644 --- a/dev/interface/index.html +++ b/dev/interface/index.html @@ -17,4 +17,4 @@ A(100.0)
10.101397401671347
Note

The values computed beyond the range of the time points provided during interpolation will not be reliable as these methods only perform well within the range and the first/last piece polynomial fit is extrapolated on either sides which might not reflect the true nature of the data.

Derivatives

Derivatives of the interpolated curves can also be computed at any point for all the methods.

We will continue with the above example, but the API is same for all the methods.

# derivative(A, t)
 DataInterpolations.derivative(A, 1.0)
-0.051048168999699245

Integrals

Integrals of the interpolated curves can also be computed easily.

Currently, this is implemented only for a few methods - ConstantInterpolation, LinearInterpolation, QuadraticInterpolation, QuadraticSpline and CubicSpline.

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

# integral(A, t)
 DataInterpolations.integral(A, 5.0)
72.86338611822583

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

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

If the times provided in the integral goes 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(A, 1.0, 5.0)
114.9694509973317
Note

If the times provided in the integral goes 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/methods/462123ae.svg b/dev/methods/1c09f9f1.svg similarity index 95% rename from dev/methods/462123ae.svg rename to dev/methods/1c09f9f1.svg index db38a649..54185300 100644 --- a/dev/methods/462123ae.svg +++ b/dev/methods/1c09f9f1.svg @@ -1,145 +1,145 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/dec33a62.svg b/dev/methods/64996f58.svg similarity index 97% rename from dev/methods/dec33a62.svg rename to dev/methods/64996f58.svg index fb9a2852..07e21892 100644 --- a/dev/methods/dec33a62.svg +++ b/dev/methods/64996f58.svg @@ -1,57 +1,57 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/f130043a.svg b/dev/methods/6c6ec359.svg similarity index 95% rename from dev/methods/f130043a.svg rename to dev/methods/6c6ec359.svg index 222a80b8..2373dc8e 100644 --- a/dev/methods/f130043a.svg +++ b/dev/methods/6c6ec359.svg @@ -1,145 +1,145 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/6e3c99a2.svg b/dev/methods/6e64260c.svg similarity index 97% rename from dev/methods/6e3c99a2.svg rename to dev/methods/6e64260c.svg index dbd26033..1eb3f4ef 100644 --- a/dev/methods/6e3c99a2.svg +++ b/dev/methods/6e64260c.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/20390be5.svg b/dev/methods/761d419e.svg similarity index 80% rename from dev/methods/20390be5.svg rename to dev/methods/761d419e.svg index 5d1c101e..837c052e 100644 --- a/dev/methods/20390be5.svg +++ b/dev/methods/761d419e.svg @@ -1,248 +1,248 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/479c6e24.svg b/dev/methods/8a582399.svg similarity index 97% rename from dev/methods/479c6e24.svg rename to dev/methods/8a582399.svg index 0565e103..dd20c5c4 100644 --- a/dev/methods/479c6e24.svg +++ b/dev/methods/8a582399.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/297a1a76.svg b/dev/methods/93e0f272.svg similarity index 97% rename from dev/methods/297a1a76.svg rename to dev/methods/93e0f272.svg index 7af60df3..c9f6e034 100644 --- a/dev/methods/297a1a76.svg +++ b/dev/methods/93e0f272.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/2022a3c3.svg b/dev/methods/a4bc4ae2.svg similarity index 97% rename from dev/methods/2022a3c3.svg rename to dev/methods/a4bc4ae2.svg index 14c913db..923bbe2e 100644 --- a/dev/methods/2022a3c3.svg +++ b/dev/methods/a4bc4ae2.svg @@ -1,53 +1,53 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/ecaa0f5c.svg b/dev/methods/ae1a54f0.svg similarity index 86% rename from dev/methods/ecaa0f5c.svg rename to dev/methods/ae1a54f0.svg index e31ec84a..24f755c3 100644 --- a/dev/methods/ecaa0f5c.svg +++ b/dev/methods/ae1a54f0.svg @@ -1,62 +1,62 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/fed69fb6.svg b/dev/methods/dd3f52cf.svg similarity index 97% rename from dev/methods/fed69fb6.svg rename to dev/methods/dd3f52cf.svg index 3555a01f..299638a9 100644 --- a/dev/methods/fed69fb6.svg +++ b/dev/methods/dd3f52cf.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/2f6a74f8.svg b/dev/methods/f5a84139.svg similarity index 97% rename from dev/methods/2f6a74f8.svg rename to dev/methods/f5a84139.svg index c43ff5f4..ad906cae 100644 --- a/dev/methods/2f6a74f8.svg +++ b/dev/methods/f5a84139.svg @@ -1,57 +1,57 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/6106d6b1.svg b/dev/methods/f74be8f3.svg similarity index 97% rename from dev/methods/6106d6b1.svg rename to dev/methods/f74be8f3.svg index 91cfe603..9eb4a803 100644 --- a/dev/methods/6106d6b1.svg +++ b/dev/methods/f74be8f3.svg @@ -1,59 +1,59 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/9f2ee4db.svg b/dev/methods/ffaf03f7.svg similarity index 97% rename from dev/methods/9f2ee4db.svg rename to dev/methods/ffaf03f7.svg index 2dc0892b..22d8eeb9 100644 --- a/dev/methods/9f2ee4db.svg +++ b/dev/methods/ffaf03f7.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/index.html b/dev/methods/index.html index c5f45bfa..42b0a9f8 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 ends points of interval of input data point.

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 in the right or the 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 in the right or the 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 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 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 value at 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 value at 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 and 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 and 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. Do 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 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. Do 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 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}:
-  1.002517318529601
-  1.0396588440356678
- -0.13178842466234678
-  1.0670107400182296

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())
+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