From 9800529735602da26f053d2a8e0eb6f4b06cee2e Mon Sep 17 00:00:00 2001 From: "Documenter.jl" Date: Sun, 14 Jan 2024 20:51:40 +0000 Subject: [PATCH] build based on 4c61559 --- dev/.documenter-siteinfo.json | 2 +- dev/assets/Manifest.toml | 14 +- dev/index.html | 8 +- dev/interface/index.html | 2 +- dev/methods/{9d269b3c.svg => 0bb5f885.svg} | 82 ++-- dev/methods/{08c9cded.svg => 13706061.svg} | 90 ++-- dev/methods/{a1b5eb81.svg => 3d660d52.svg} | 262 ++++++------ dev/methods/{99c432dc.svg => 4db4348f.svg} | 78 ++-- dev/methods/{9a4d165e.svg => 6efc122d.svg} | 82 ++-- dev/methods/{74ae53af.svg => 7106bd8d.svg} | 468 ++++++++++----------- dev/methods/{a106c477.svg => 83f59876.svg} | 82 ++-- dev/methods/{855d6563.svg => a4e9c57d.svg} | 262 ++++++------ dev/methods/{821d2dab.svg => d37f4144.svg} | 86 ++-- dev/methods/{86fefff1.svg => d7ae5168.svg} | 96 ++--- dev/methods/{7dd201a3.svg => e013b68e.svg} | 86 ++-- dev/methods/{4e1fcbdf.svg => eecf5610.svg} | 82 ++-- dev/methods/{c3440be8.svg => ff81928d.svg} | 82 ++-- dev/methods/index.html | 28 +- 18 files changed, 946 insertions(+), 946 deletions(-) rename dev/methods/{9d269b3c.svg => 0bb5f885.svg} (97%) rename dev/methods/{08c9cded.svg => 13706061.svg} (97%) rename dev/methods/{a1b5eb81.svg => 3d660d52.svg} (95%) rename dev/methods/{99c432dc.svg => 4db4348f.svg} (97%) rename dev/methods/{9a4d165e.svg => 6efc122d.svg} (97%) rename dev/methods/{74ae53af.svg => 7106bd8d.svg} (80%) rename dev/methods/{a106c477.svg => 83f59876.svg} (97%) rename dev/methods/{855d6563.svg => a4e9c57d.svg} (95%) rename dev/methods/{821d2dab.svg => d37f4144.svg} (97%) rename dev/methods/{86fefff1.svg => d7ae5168.svg} (86%) rename dev/methods/{7dd201a3.svg => e013b68e.svg} (97%) rename dev/methods/{4e1fcbdf.svg => eecf5610.svg} (97%) rename dev/methods/{c3440be8.svg => ff81928d.svg} (97%) diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index f470edd6..a6a70b17 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.10.0","generation_timestamp":"2024-01-09T02:22:26","documenter_version":"1.2.1"}} \ No newline at end of file +{"documenter":{"julia_version":"1.10.0","generation_timestamp":"2024-01-14T20:51:35","documenter_version":"1.2.1"}} \ No newline at end of file diff --git a/dev/assets/Manifest.toml b/dev/assets/Manifest.toml index 4b1bfb13..ee791cc6 100644 --- a/dev/assets/Manifest.toml +++ b/dev/assets/Manifest.toml @@ -65,9 +65,9 @@ version = "0.1.8" [[deps.Bzip2_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] -git-tree-sha1 = "19a35467a82e236ff51bc17a3a44b69ef35185a2" +git-tree-sha1 = "9e2a6b69137e6969bab0152632dcb3bc108c8bdd" uuid = "6e34b625-4abd-537c-b88f-471c36dfa7a0" -version = "1.0.8+0" +version = "1.0.8+1" [[deps.Cairo_jll]] deps = ["Artifacts", "Bzip2_jll", "CompilerSupportLibraries_jll", "Fontconfig_jll", "FreeType2_jll", "Glib_jll", "JLLWrappers", "LZO_jll", "Libdl", "Pixman_jll", "Pkg", "Xorg_libXext_jll", "Xorg_libXrender_jll", "Zlib_jll", "libpng_jll"] @@ -122,10 +122,10 @@ uuid = "bbf7d656-a473-5ed7-a52c-81e309532950" version = "0.3.0" [[deps.Compat]] -deps = ["UUIDs"] -git-tree-sha1 = "886826d76ea9e72b35fcd000e535588f7b60f21d" +deps = ["TOML", "UUIDs"] +git-tree-sha1 = "75bd5b6fc5089df449b5d35fa501c846c9b6549b" uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" -version = "4.10.1" +version = "4.12.0" weakdeps = ["Dates", "LinearAlgebra"] [deps.Compat.extensions] @@ -387,9 +387,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 = "bb8f7cc77ec1152414b2af6db533d9471cfbb2d1" +git-tree-sha1 = "b30c473c97fcc1e1e44fab8f3e88fd1b89c9e9d1" uuid = "f8c6e375-362e-5223-8a59-34ff63f689eb" -version = "2.42.0+0" +version = "2.43.0+0" [[deps.Glib_jll]] deps = ["Artifacts", "Gettext_jll", "JLLWrappers", "Libdl", "Libffi_jll", "Libiconv_jll", "Libmount_jll", "PCRE2_jll", "Zlib_jll"] diff --git a/dev/index.html b/dev/index.html index 967a8aed..2acc8bc5 100644 --- a/dev/index.html +++ b/dev/index.html @@ -29,7 +29,7 @@ [c3611d14] ColorVectorSpace v0.10.0 [5ae59095] Colors v0.12.10 [bbf7d656] CommonSubexpressions v0.3.0 - [34da2185] Compat v4.10.1 + [34da2185] Compat v4.12.0 [f0e56b4a] ConcurrentUtilities v2.3.0 [187b0558] ConstructionBase v1.5.4 [d38c429a] Contour v0.6.2 @@ -119,7 +119,7 @@ [1986cc42] Unitful v1.19.0 [45397f5d] UnitfulLatexify v1.6.3 [41fe7b60] Unzip v0.2.0 - [6e34b625] Bzip2_jll v1.0.8+0 + [6e34b625] Bzip2_jll v1.0.8+1 [83423d85] Cairo_jll v1.16.1+1 [2702e6a9] EpollShim_jll v0.0.20230411+0 [2e619515] Expat_jll v2.5.0+0 @@ -130,7 +130,7 @@ [0656b61e] GLFW_jll v3.3.9+0 ⌅ [d2c73de3] GR_jll v0.72.10+0 [78b55507] Gettext_jll v0.21.0+0 - [f8c6e375] Git_jll v2.42.0+0 + [f8c6e375] Git_jll v2.43.0+0 [7746bdde] Glib_jll v2.76.5+0 [3b182d85] Graphite2_jll v1.3.14+0 [2e76f6c2] HarfBuzz_jll v2.8.1+1 @@ -244,4 +244,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 1dc57559..dd5bec1e 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/methods/9d269b3c.svg b/dev/methods/0bb5f885.svg similarity index 97% rename from dev/methods/9d269b3c.svg rename to dev/methods/0bb5f885.svg index 2c27693f..203040e2 100644 --- a/dev/methods/9d269b3c.svg +++ b/dev/methods/0bb5f885.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/08c9cded.svg b/dev/methods/13706061.svg similarity index 97% rename from dev/methods/08c9cded.svg rename to dev/methods/13706061.svg index c6c8de03..bdc2aa1f 100644 --- a/dev/methods/08c9cded.svg +++ b/dev/methods/13706061.svg @@ -1,59 +1,59 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/a1b5eb81.svg b/dev/methods/3d660d52.svg similarity index 95% rename from dev/methods/a1b5eb81.svg rename to dev/methods/3d660d52.svg index c713987b..ba5a891c 100644 --- a/dev/methods/a1b5eb81.svg +++ b/dev/methods/3d660d52.svg @@ -1,145 +1,145 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/99c432dc.svg b/dev/methods/4db4348f.svg similarity index 97% rename from dev/methods/99c432dc.svg rename to dev/methods/4db4348f.svg index 3cd51e2a..6359439c 100644 --- a/dev/methods/99c432dc.svg +++ b/dev/methods/4db4348f.svg @@ -1,53 +1,53 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/9a4d165e.svg b/dev/methods/6efc122d.svg similarity index 97% rename from dev/methods/9a4d165e.svg rename to dev/methods/6efc122d.svg index 18823625..b679b42d 100644 --- a/dev/methods/9a4d165e.svg +++ b/dev/methods/6efc122d.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/74ae53af.svg b/dev/methods/7106bd8d.svg similarity index 80% rename from dev/methods/74ae53af.svg rename to dev/methods/7106bd8d.svg index 828eca20..307c3419 100644 --- a/dev/methods/74ae53af.svg +++ b/dev/methods/7106bd8d.svg @@ -1,248 +1,248 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/a106c477.svg b/dev/methods/83f59876.svg similarity index 97% rename from dev/methods/a106c477.svg rename to dev/methods/83f59876.svg index 08f20fd1..fda7adc9 100644 --- a/dev/methods/a106c477.svg +++ b/dev/methods/83f59876.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/855d6563.svg b/dev/methods/a4e9c57d.svg similarity index 95% rename from dev/methods/855d6563.svg rename to dev/methods/a4e9c57d.svg index d2a77946..a9d177ef 100644 --- a/dev/methods/855d6563.svg +++ b/dev/methods/a4e9c57d.svg @@ -1,145 +1,145 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/821d2dab.svg b/dev/methods/d37f4144.svg similarity index 97% rename from dev/methods/821d2dab.svg rename to dev/methods/d37f4144.svg index 4c2bbe82..53496527 100644 --- a/dev/methods/821d2dab.svg +++ b/dev/methods/d37f4144.svg @@ -1,57 +1,57 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/86fefff1.svg b/dev/methods/d7ae5168.svg similarity index 86% rename from dev/methods/86fefff1.svg rename to dev/methods/d7ae5168.svg index ed07aa44..58bcb46c 100644 --- a/dev/methods/86fefff1.svg +++ b/dev/methods/d7ae5168.svg @@ -1,62 +1,62 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/7dd201a3.svg b/dev/methods/e013b68e.svg similarity index 97% rename from dev/methods/7dd201a3.svg rename to dev/methods/e013b68e.svg index 101347b6..4ab499c5 100644 --- a/dev/methods/7dd201a3.svg +++ b/dev/methods/e013b68e.svg @@ -1,57 +1,57 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/4e1fcbdf.svg b/dev/methods/eecf5610.svg similarity index 97% rename from dev/methods/4e1fcbdf.svg rename to dev/methods/eecf5610.svg index 20ccfdb8..40dbebdf 100644 --- a/dev/methods/4e1fcbdf.svg +++ b/dev/methods/eecf5610.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/c3440be8.svg b/dev/methods/ff81928d.svg similarity index 97% rename from dev/methods/c3440be8.svg rename to dev/methods/ff81928d.svg index bde642c7..e16c5de0 100644 --- a/dev/methods/c3440be8.svg +++ b/dev/methods/ff81928d.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/index.html b/dev/methods/index.html index 80ef5de9..ff05d35a 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