From 7e77997be3a3ef80dbd843608ac2d04db77cae28 Mon Sep 17 00:00:00 2001 From: "Documenter.jl" Date: Sun, 22 Oct 2023 16:40:22 +0000 Subject: [PATCH] build based on 98e9ffa --- dev/.documenter-siteinfo.json | 2 +- dev/index.html | 17 +- dev/interface/index.html | 2 +- dev/methods/{e5af3fe5.svg => 2022a3c3.svg} | 78 ++-- dev/methods/{cee193f9.svg => 20390be5.svg} | 468 ++++++++++----------- dev/methods/{fb8f3ce7.svg => 297a1a76.svg} | 82 ++-- dev/methods/{74304a4a.svg => 2f6a74f8.svg} | 86 ++-- dev/methods/{2212883f.svg => 462123ae.svg} | 262 ++++++------ dev/methods/{f367190c.svg => 479c6e24.svg} | 82 ++-- dev/methods/{498eb7a4.svg => 6106d6b1.svg} | 90 ++-- dev/methods/{5469db57.svg => 6e3c99a2.svg} | 82 ++-- dev/methods/{d661aff9.svg => 9f2ee4db.svg} | 82 ++-- dev/methods/{d60e0567.svg => dec33a62.svg} | 86 ++-- dev/methods/{3dd26aaa.svg => ecaa0f5c.svg} | 96 ++--- dev/methods/{c76b6f5a.svg => f130043a.svg} | 262 ++++++------ dev/methods/{0cf31c30.svg => fed69fb6.svg} | 82 ++-- dev/methods/index.html | 28 +- 17 files changed, 945 insertions(+), 942 deletions(-) rename dev/methods/{e5af3fe5.svg => 2022a3c3.svg} (97%) rename dev/methods/{cee193f9.svg => 20390be5.svg} (80%) rename dev/methods/{fb8f3ce7.svg => 297a1a76.svg} (97%) rename dev/methods/{74304a4a.svg => 2f6a74f8.svg} (97%) rename dev/methods/{2212883f.svg => 462123ae.svg} (95%) rename dev/methods/{f367190c.svg => 479c6e24.svg} (97%) rename dev/methods/{498eb7a4.svg => 6106d6b1.svg} (97%) rename dev/methods/{5469db57.svg => 6e3c99a2.svg} (97%) rename dev/methods/{d661aff9.svg => 9f2ee4db.svg} (97%) rename dev/methods/{d60e0567.svg => dec33a62.svg} (97%) rename dev/methods/{3dd26aaa.svg => ecaa0f5c.svg} (86%) rename dev/methods/{c76b6f5a.svg => f130043a.svg} (95%) rename dev/methods/{0cf31c30.svg => fed69fb6.svg} (97%) diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index 68c8cfdf..6f59ad4c 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.9.3","generation_timestamp":"2023-10-17T10:32:52","documenter_version":"1.1.1"}} \ No newline at end of file +{"documenter":{"julia_version":"1.9.3","generation_timestamp":"2023-10-22T16:40:15","documenter_version":"1.1.1"}} \ No newline at end of file diff --git a/dev/index.html b/dev/index.html index 5f82c5df..61035a35 100644 --- a/dev/index.html +++ b/dev/index.html @@ -12,7 +12,7 @@ Official https://julialang.org/ release Platform Info: OS: Linux (x86_64-linux-gnu) - CPU: 2 × Intel(R) Xeon(R) Platinum 8171M CPU @ 2.60GHz + CPU: 2 × Intel(R) Xeon(R) Platinum 8272CL CPU @ 2.60GHz WORD_SIZE: 64 LIBM: libopenlibm LLVM: libLLVM-14.0.6 (ORCJIT, skylake-avx512) @@ -33,6 +33,7 @@ [f0e56b4a] ConcurrentUtilities v2.2.1 [187b0558] ConstructionBase v1.5.4 [d38c429a] Contour v0.6.2 + [a8cc5b0e] Crayons v4.1.1 [9a962f9c] DataAPI v1.15.0 [82cc6244] DataInterpolations v4.4.0 `~/work/DataInterpolations.jl/DataInterpolations.jl` [864edb3b] DataStructures v0.18.15 @@ -44,7 +45,7 @@ [e30172f5] Documenter v1.1.1 [460bff9d] ExceptionUnwrapping v0.1.9 [c87230d0] FFMPEG v0.4.1 - [1a297f60] FillArrays v1.6.1 + [1a297f60] FillArrays v1.7.0 [6a86dc24] FiniteDiff v2.21.1 [53c48c17] FixedPointNumbers v0.8.4 [59287772] Formatting v0.4.2 @@ -88,9 +89,10 @@ [85a6dd25] PositiveFactorizations v0.2.4 [aea7be01] PrecompileTools v1.2.0 [21216c6a] Preferences v1.4.1 + [08abe8d2] PrettyTables v2.2.8 [3cdcf5f2] RecipesBase v1.3.4 [01d81517] RecipesPipeline v0.6.12 - [731186ca] RecursiveArrayTools v2.39.0 + [731186ca] RecursiveArrayTools v2.38.10 [189a3867] Reexport v1.2.2 [2792f1a3] RegistryInstances v0.1.0 [29dad682] RegularizationTools v0.6.0 @@ -100,17 +102,18 @@ [efcf1570] Setfield v1.1.1 [992d4aef] Showoff v1.0.3 [777ac1f9] SimpleBufferStream v1.1.0 - [a2af1166] SortingAlgorithms v1.1.1 + [a2af1166] SortingAlgorithms v1.2.0 [276daf66] SpecialFunctions v2.3.1 [860ef19b] StableRNGs v1.0.0 [1e83bf80] StaticArraysCore v1.4.2 [82ae8749] StatsAPI v1.7.0 [2913bbd2] StatsBase v0.34.2 + [892a3eda] StringManipulation v0.3.4 [2efcf032] SymbolicIndexingInterface v0.2.2 [3783bdb8] TableTraits v1.0.1 - [bd369af6] Tables v1.11.0 + [bd369af6] Tables v1.11.1 [62fd8b95] TensorCore v0.1.1 - [3bb67fe8] TranscodingStreams v0.10.0 + [3bb67fe8] TranscodingStreams v0.10.1 [5c2747f8] URIs v1.5.1 [3a884ed6] UnPack v1.0.2 [d9a01c3f] Underscores v3.0.0 @@ -241,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 ⌃ 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.

diff --git a/dev/interface/index.html b/dev/interface/index.html index 58903234..10572245 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/e5af3fe5.svg b/dev/methods/2022a3c3.svg similarity index 97% rename from dev/methods/e5af3fe5.svg rename to dev/methods/2022a3c3.svg index 0e48d5f3..14c913db 100644 --- a/dev/methods/e5af3fe5.svg +++ b/dev/methods/2022a3c3.svg @@ -1,53 +1,53 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/cee193f9.svg b/dev/methods/20390be5.svg similarity index 80% rename from dev/methods/cee193f9.svg rename to dev/methods/20390be5.svg index bf7840f8..5d1c101e 100644 --- a/dev/methods/cee193f9.svg +++ b/dev/methods/20390be5.svg @@ -1,248 +1,248 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/fb8f3ce7.svg b/dev/methods/297a1a76.svg similarity index 97% rename from dev/methods/fb8f3ce7.svg rename to dev/methods/297a1a76.svg index af0794db..7af60df3 100644 --- a/dev/methods/fb8f3ce7.svg +++ b/dev/methods/297a1a76.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/74304a4a.svg b/dev/methods/2f6a74f8.svg similarity index 97% rename from dev/methods/74304a4a.svg rename to dev/methods/2f6a74f8.svg index 2613701b..c43ff5f4 100644 --- a/dev/methods/74304a4a.svg +++ b/dev/methods/2f6a74f8.svg @@ -1,57 +1,57 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/2212883f.svg b/dev/methods/462123ae.svg similarity index 95% rename from dev/methods/2212883f.svg rename to dev/methods/462123ae.svg index a081d24a..db38a649 100644 --- a/dev/methods/2212883f.svg +++ b/dev/methods/462123ae.svg @@ -1,145 +1,145 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/f367190c.svg b/dev/methods/479c6e24.svg similarity index 97% rename from dev/methods/f367190c.svg rename to dev/methods/479c6e24.svg index a7546851..0565e103 100644 --- a/dev/methods/f367190c.svg +++ b/dev/methods/479c6e24.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/498eb7a4.svg b/dev/methods/6106d6b1.svg similarity index 97% rename from dev/methods/498eb7a4.svg rename to dev/methods/6106d6b1.svg index 7cd1dd2d..91cfe603 100644 --- a/dev/methods/498eb7a4.svg +++ b/dev/methods/6106d6b1.svg @@ -1,59 +1,59 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/5469db57.svg b/dev/methods/6e3c99a2.svg similarity index 97% rename from dev/methods/5469db57.svg rename to dev/methods/6e3c99a2.svg index cf147906..dbd26033 100644 --- a/dev/methods/5469db57.svg +++ b/dev/methods/6e3c99a2.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/d661aff9.svg b/dev/methods/9f2ee4db.svg similarity index 97% rename from dev/methods/d661aff9.svg rename to dev/methods/9f2ee4db.svg index 0bbf9775..2dc0892b 100644 --- a/dev/methods/d661aff9.svg +++ b/dev/methods/9f2ee4db.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/d60e0567.svg b/dev/methods/dec33a62.svg similarity index 97% rename from dev/methods/d60e0567.svg rename to dev/methods/dec33a62.svg index 4322b41a..fb9a2852 100644 --- a/dev/methods/d60e0567.svg +++ b/dev/methods/dec33a62.svg @@ -1,57 +1,57 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/3dd26aaa.svg b/dev/methods/ecaa0f5c.svg similarity index 86% rename from dev/methods/3dd26aaa.svg rename to dev/methods/ecaa0f5c.svg index 25001374..e31ec84a 100644 --- a/dev/methods/3dd26aaa.svg +++ b/dev/methods/ecaa0f5c.svg @@ -1,62 +1,62 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/c76b6f5a.svg b/dev/methods/f130043a.svg similarity index 95% rename from dev/methods/c76b6f5a.svg rename to dev/methods/f130043a.svg index 8b83b3d3..222a80b8 100644 --- a/dev/methods/c76b6f5a.svg +++ b/dev/methods/f130043a.svg @@ -1,145 +1,145 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/0cf31c30.svg b/dev/methods/fed69fb6.svg similarity index 97% rename from dev/methods/0cf31c30.svg rename to dev/methods/fed69fb6.svg index bd627abc..3555a01f 100644 --- a/dev/methods/0cf31c30.svg +++ b/dev/methods/fed69fb6.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/index.html b/dev/methods/index.html index 4253d3b9..c5f45bfa 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}:
+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())
 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