From 5e173275094b21a6edca0810f8695cb1de01bca5 Mon Sep 17 00:00:00 2001 From: "Documenter.jl" Date: Sun, 7 Jan 2024 01:08:14 +0000 Subject: [PATCH] build based on 47af322 --- dev/.documenter-siteinfo.json | 2 +- dev/assets/Manifest.toml | 12 +- dev/index.html | 8 +- dev/interface/index.html | 2 +- dev/methods/{c99ba59e.svg => 025bed47.svg} | 262 ++++++------ dev/methods/{c0d5db56.svg => 11da5ae1.svg} | 262 ++++++------ dev/methods/{7edd06df.svg => 2ca01200.svg} | 82 ++-- dev/methods/{ba7fca14.svg => 3043cbad.svg} | 82 ++-- dev/methods/{a7a20c98.svg => 33b72b64.svg} | 82 ++-- dev/methods/{9771a179.svg => 7cdf6c79.svg} | 86 ++-- dev/methods/{7ef9477d.svg => 9415f5a3.svg} | 468 ++++++++++----------- dev/methods/{60f53e83.svg => 94a16e31.svg} | 96 ++--- dev/methods/{674d43d6.svg => 9840cd05.svg} | 78 ++-- dev/methods/{d9ba0985.svg => c013bcd6.svg} | 90 ++-- dev/methods/{534e4780.svg => cc9aaca8.svg} | 82 ++-- dev/methods/{1776a4ff.svg => d210f574.svg} | 82 ++-- dev/methods/{af163bf5.svg => e49c6405.svg} | 86 ++-- dev/methods/index.html | 28 +- 18 files changed, 945 insertions(+), 945 deletions(-) rename dev/methods/{c99ba59e.svg => 025bed47.svg} (95%) rename dev/methods/{c0d5db56.svg => 11da5ae1.svg} (95%) rename dev/methods/{7edd06df.svg => 2ca01200.svg} (97%) rename dev/methods/{ba7fca14.svg => 3043cbad.svg} (97%) rename dev/methods/{a7a20c98.svg => 33b72b64.svg} (97%) rename dev/methods/{9771a179.svg => 7cdf6c79.svg} (97%) rename dev/methods/{7ef9477d.svg => 9415f5a3.svg} (80%) rename dev/methods/{60f53e83.svg => 94a16e31.svg} (86%) rename dev/methods/{674d43d6.svg => 9840cd05.svg} (97%) rename dev/methods/{d9ba0985.svg => c013bcd6.svg} (97%) rename dev/methods/{534e4780.svg => cc9aaca8.svg} (97%) rename dev/methods/{1776a4ff.svg => d210f574.svg} (97%) rename dev/methods/{af163bf5.svg => e49c6405.svg} (97%) diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index 89ad4a5d..739a03cc 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.10.0","generation_timestamp":"2023-12-29T14:04:04","documenter_version":"1.2.1"}} \ No newline at end of file +{"documenter":{"julia_version":"1.10.0","generation_timestamp":"2024-01-07T01:08:09","documenter_version":"1.2.1"}} \ No newline at end of file diff --git a/dev/assets/Manifest.toml b/dev/assets/Manifest.toml index 89c1cbac..4b1bfb13 100644 --- a/dev/assets/Manifest.toml +++ b/dev/assets/Manifest.toml @@ -192,9 +192,9 @@ version = "4.6.0" [[deps.DataStructures]] deps = ["Compat", "InteractiveUtils", "OrderedCollections"] -git-tree-sha1 = "3dbd312d370723b6bb43ba9d02fc36abade4518d" +git-tree-sha1 = "ac67408d9ddf207de5cfa9a97e114352430f01ed" uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" -version = "0.18.15" +version = "0.18.16" [[deps.DataValueInterfaces]] git-tree-sha1 = "bfc1187b79289637fa0ef6d4436ebdfe6905cbd6" @@ -252,9 +252,9 @@ version = "0.0.20230411+0" [[deps.ExceptionUnwrapping]] deps = ["Test"] -git-tree-sha1 = "e90caa41f5a86296e014e148ee061bd6c3edec96" +git-tree-sha1 = "dcb08a0d93ec0b1cdc4af184b26b591e9695423a" uuid = "460bff9d-24e4-43bc-9d9f-a8973cb893f4" -version = "0.1.9" +version = "0.1.10" [[deps.Expat_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl"] @@ -1112,9 +1112,9 @@ version = "1.21.0+1" [[deps.Wayland_protocols_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] -git-tree-sha1 = "4528479aa01ee1b3b4cd0e6faef0e04cf16466da" +git-tree-sha1 = "93f43ab61b16ddfb2fd3bb13b3ce241cafb0e6c9" uuid = "2381bf8a-dfd0-557d-9999-79630e7b1b91" -version = "1.25.0+0" +version = "1.31.0+0" [[deps.XML2_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl", "Libiconv_jll", "Zlib_jll"] diff --git a/dev/index.html b/dev/index.html index 59723ea5..59305b1b 100644 --- a/dev/index.html +++ b/dev/index.html @@ -36,14 +36,14 @@ [a8cc5b0e] Crayons v4.1.1 [9a962f9c] DataAPI v1.15.0 [82cc6244] DataInterpolations v4.6.0 `~/work/DataInterpolations.jl/DataInterpolations.jl` - [864edb3b] DataStructures v0.18.15 + [864edb3b] DataStructures v0.18.16 [e2d170a0] DataValueInterfaces v1.0.0 [8bb1440f] DelimitedFiles v1.9.1 [163ba53b] DiffResults v1.1.0 [b552c78f] DiffRules v1.15.1 [ffbed154] DocStringExtensions v0.9.3 [e30172f5] Documenter v1.2.1 - [460bff9d] ExceptionUnwrapping v0.1.9 + [460bff9d] ExceptionUnwrapping v0.1.10 [c87230d0] FFMPEG v0.4.1 [1a297f60] FillArrays v1.9.3 [6a86dc24] FiniteDiff v2.22.0 @@ -155,7 +155,7 @@ [c0090381] Qt6Base_jll v6.5.3+1 [a44049a8] Vulkan_Loader_jll v1.3.243+0 [a2964d1f] Wayland_jll v1.21.0+1 - [2381bf8a] Wayland_protocols_jll v1.25.0+0 + [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.5+0 @@ -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 b73d53b8..8f51c7a6 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/c99ba59e.svg b/dev/methods/025bed47.svg similarity index 95% rename from dev/methods/c99ba59e.svg rename to dev/methods/025bed47.svg index 827c5804..826cec8e 100644 --- a/dev/methods/c99ba59e.svg +++ b/dev/methods/025bed47.svg @@ -1,145 +1,145 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/c0d5db56.svg b/dev/methods/11da5ae1.svg similarity index 95% rename from dev/methods/c0d5db56.svg rename to dev/methods/11da5ae1.svg index 772485de..252875ec 100644 --- a/dev/methods/c0d5db56.svg +++ b/dev/methods/11da5ae1.svg @@ -1,145 +1,145 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/7edd06df.svg b/dev/methods/2ca01200.svg similarity index 97% rename from dev/methods/7edd06df.svg rename to dev/methods/2ca01200.svg index 4740ebff..a295935c 100644 --- a/dev/methods/7edd06df.svg +++ b/dev/methods/2ca01200.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/ba7fca14.svg b/dev/methods/3043cbad.svg similarity index 97% rename from dev/methods/ba7fca14.svg rename to dev/methods/3043cbad.svg index 0c3d7493..b3044b96 100644 --- a/dev/methods/ba7fca14.svg +++ b/dev/methods/3043cbad.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/a7a20c98.svg b/dev/methods/33b72b64.svg similarity index 97% rename from dev/methods/a7a20c98.svg rename to dev/methods/33b72b64.svg index 32ea97a8..ea17288e 100644 --- a/dev/methods/a7a20c98.svg +++ b/dev/methods/33b72b64.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/9771a179.svg b/dev/methods/7cdf6c79.svg similarity index 97% rename from dev/methods/9771a179.svg rename to dev/methods/7cdf6c79.svg index b3ad73d4..aa51cba7 100644 --- a/dev/methods/9771a179.svg +++ b/dev/methods/7cdf6c79.svg @@ -1,57 +1,57 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/7ef9477d.svg b/dev/methods/9415f5a3.svg similarity index 80% rename from dev/methods/7ef9477d.svg rename to dev/methods/9415f5a3.svg index 24b581ca..30967442 100644 --- a/dev/methods/7ef9477d.svg +++ b/dev/methods/9415f5a3.svg @@ -1,248 +1,248 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/60f53e83.svg b/dev/methods/94a16e31.svg similarity index 86% rename from dev/methods/60f53e83.svg rename to dev/methods/94a16e31.svg index cd8ae0ab..f1d1208a 100644 --- a/dev/methods/60f53e83.svg +++ b/dev/methods/94a16e31.svg @@ -1,62 +1,62 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/674d43d6.svg b/dev/methods/9840cd05.svg similarity index 97% rename from dev/methods/674d43d6.svg rename to dev/methods/9840cd05.svg index 625665f2..3d7c4499 100644 --- a/dev/methods/674d43d6.svg +++ b/dev/methods/9840cd05.svg @@ -1,53 +1,53 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/d9ba0985.svg b/dev/methods/c013bcd6.svg similarity index 97% rename from dev/methods/d9ba0985.svg rename to dev/methods/c013bcd6.svg index ed4a2010..37d2bccf 100644 --- a/dev/methods/d9ba0985.svg +++ b/dev/methods/c013bcd6.svg @@ -1,59 +1,59 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/534e4780.svg b/dev/methods/cc9aaca8.svg similarity index 97% rename from dev/methods/534e4780.svg rename to dev/methods/cc9aaca8.svg index 9c680bbd..79a94997 100644 --- a/dev/methods/534e4780.svg +++ b/dev/methods/cc9aaca8.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/1776a4ff.svg b/dev/methods/d210f574.svg similarity index 97% rename from dev/methods/1776a4ff.svg rename to dev/methods/d210f574.svg index a39e01c8..3bf817a1 100644 --- a/dev/methods/1776a4ff.svg +++ b/dev/methods/d210f574.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/af163bf5.svg b/dev/methods/e49c6405.svg similarity index 97% rename from dev/methods/af163bf5.svg rename to dev/methods/e49c6405.svg index 2235f52f..8489a59a 100644 --- a/dev/methods/af163bf5.svg +++ b/dev/methods/e49c6405.svg @@ -1,57 +1,57 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/index.html b/dev/methods/index.html index f393dcec..bf1c9b3f 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