From bae2a03ac9d5b215007a4582c7781fb1d5f6678b Mon Sep 17 00:00:00 2001 From: "Documenter.jl" Date: Wed, 6 Dec 2023 14:29:26 +0000 Subject: [PATCH] build based on d50ae1b --- dev/.documenter-siteinfo.json | 2 +- dev/index.html | 9 +- dev/interface/index.html | 2 +- dev/methods/{eadb84df.svg => 0433d075.svg} | 82 ++-- dev/methods/{f28aca58.svg => 12ed7b0c.svg} | 96 ++--- dev/methods/{f53a757c.svg => 2f7a9ada.svg} | 82 ++-- dev/methods/{dae36c17.svg => 474a6603.svg} | 82 ++-- dev/methods/{c5d75d0b.svg => 5609025a.svg} | 262 ++++++------ dev/methods/{6ee61843.svg => 5b2c3944.svg} | 468 ++++++++++----------- dev/methods/{fdfa0cff.svg => 8ace5c38.svg} | 86 ++-- dev/methods/{825deccd.svg => a79627b9.svg} | 86 ++-- dev/methods/{a072a720.svg => b2daf2a0.svg} | 262 ++++++------ dev/methods/{0206e490.svg => ba37fc0d.svg} | 90 ++-- dev/methods/{5cc9d6ff.svg => d74f0fc4.svg} | 78 ++-- dev/methods/{924d789c.svg => dd25ccee.svg} | 82 ++-- dev/methods/{990f3049.svg => e3f3e0d7.svg} | 82 ++-- dev/methods/index.html | 28 +- 17 files changed, 938 insertions(+), 941 deletions(-) rename dev/methods/{eadb84df.svg => 0433d075.svg} (97%) rename dev/methods/{f28aca58.svg => 12ed7b0c.svg} (86%) rename dev/methods/{f53a757c.svg => 2f7a9ada.svg} (97%) rename dev/methods/{dae36c17.svg => 474a6603.svg} (97%) rename dev/methods/{c5d75d0b.svg => 5609025a.svg} (95%) rename dev/methods/{6ee61843.svg => 5b2c3944.svg} (80%) rename dev/methods/{fdfa0cff.svg => 8ace5c38.svg} (97%) rename dev/methods/{825deccd.svg => a79627b9.svg} (97%) rename dev/methods/{a072a720.svg => b2daf2a0.svg} (95%) rename dev/methods/{0206e490.svg => ba37fc0d.svg} (97%) rename dev/methods/{5cc9d6ff.svg => d74f0fc4.svg} (97%) rename dev/methods/{924d789c.svg => dd25ccee.svg} (97%) rename dev/methods/{990f3049.svg => e3f3e0d7.svg} (97%) diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index 2ef15dba..5b5059db 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.9.4","generation_timestamp":"2023-12-06T00:21:59","documenter_version":"1.2.1"}} \ No newline at end of file +{"documenter":{"julia_version":"1.9.4","generation_timestamp":"2023-12-06T14:29:20","documenter_version":"1.2.1"}} \ No newline at end of file diff --git a/dev/index.html b/dev/index.html index 4af3f227..dc7ca463 100644 --- a/dev/index.html +++ b/dev/index.html @@ -50,7 +50,6 @@ [53c48c17] FixedPointNumbers v0.8.4 [59287772] Formatting v0.4.2 [f6369f11] ForwardDiff v0.10.36 - [46192b85] GPUArraysCore v0.1.5 [28b8d3ca] GR v0.72.10 [d7ba0133] Git v1.3.0 [42e2da0e] Grisu v1.0.2 @@ -93,7 +92,6 @@ [08abe8d2] PrettyTables v2.3.1 [3cdcf5f2] RecipesBase v1.3.4 [01d81517] RecipesPipeline v0.6.12 - [731186ca] RecursiveArrayTools v2.38.10 [189a3867] Reexport v1.2.2 [2792f1a3] RegistryInstances v0.1.0 [29dad682] RegularizationTools v0.6.0 @@ -110,7 +108,6 @@ [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.1 [62fd8b95] TensorCore v0.1.1 @@ -159,7 +156,7 @@ [a44049a8] Vulkan_Loader_jll v1.3.243+0 [a2964d1f] Wayland_jll v1.21.0+1 [2381bf8a] Wayland_protocols_jll v1.25.0+0 - [02c8fc9c] XML2_jll v2.12.0+0 + [02c8fc9c] XML2_jll v2.12.2+0 [aed1982a] XSLT_jll v1.1.34+0 [ffd25f8a] XZ_jll v5.4.5+0 [f67eecfb] Xorg_libICE_jll v1.0.10+1 @@ -195,7 +192,7 @@ [2db6ffa8] libevdev_jll v1.11.0+0 [f638f0a6] libfdk_aac_jll v2.0.2+0 [36db933b] libinput_jll v1.18.0+0 - [b53b4c65] libpng_jll v1.6.38+0 + [b53b4c65] libpng_jll v1.6.38+1 [f27f6e37] libvorbis_jll v1.3.7+1 [009596ad] mtdev_jll v1.1.6+0 [1270edf5] x264_jll v2021.5.5+0 @@ -246,4 +243,4 @@ [8e850b90] libblastrampoline_jll v5.8.0+0 [8e850ede] nghttp2_jll v1.52.0+1 [3f19e933] p7zip_jll v17.4.0+0 -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 1eefa737..3a20e50b 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 for the same 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 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(A2, 200.0, 300.0)
1065.2015077631368
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/eadb84df.svg b/dev/methods/0433d075.svg similarity index 97% rename from dev/methods/eadb84df.svg rename to dev/methods/0433d075.svg index 4e1c80b3..e10da78e 100644 --- a/dev/methods/eadb84df.svg +++ b/dev/methods/0433d075.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/f28aca58.svg b/dev/methods/12ed7b0c.svg similarity index 86% rename from dev/methods/f28aca58.svg rename to dev/methods/12ed7b0c.svg index 9da5f6a4..9d79ca6b 100644 --- a/dev/methods/f28aca58.svg +++ b/dev/methods/12ed7b0c.svg @@ -1,62 +1,62 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/f53a757c.svg b/dev/methods/2f7a9ada.svg similarity index 97% rename from dev/methods/f53a757c.svg rename to dev/methods/2f7a9ada.svg index d3f7c1fd..dbef7b05 100644 --- a/dev/methods/f53a757c.svg +++ b/dev/methods/2f7a9ada.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/dae36c17.svg b/dev/methods/474a6603.svg similarity index 97% rename from dev/methods/dae36c17.svg rename to dev/methods/474a6603.svg index d3a26fd5..7ef4f5d0 100644 --- a/dev/methods/dae36c17.svg +++ b/dev/methods/474a6603.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/c5d75d0b.svg b/dev/methods/5609025a.svg similarity index 95% rename from dev/methods/c5d75d0b.svg rename to dev/methods/5609025a.svg index 56113529..89e440c9 100644 --- a/dev/methods/c5d75d0b.svg +++ b/dev/methods/5609025a.svg @@ -1,145 +1,145 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/6ee61843.svg b/dev/methods/5b2c3944.svg similarity index 80% rename from dev/methods/6ee61843.svg rename to dev/methods/5b2c3944.svg index 7bf9040d..b0093d0e 100644 --- a/dev/methods/6ee61843.svg +++ b/dev/methods/5b2c3944.svg @@ -1,248 +1,248 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/fdfa0cff.svg b/dev/methods/8ace5c38.svg similarity index 97% rename from dev/methods/fdfa0cff.svg rename to dev/methods/8ace5c38.svg index 681c42d8..0aea8da4 100644 --- a/dev/methods/fdfa0cff.svg +++ b/dev/methods/8ace5c38.svg @@ -1,57 +1,57 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/825deccd.svg b/dev/methods/a79627b9.svg similarity index 97% rename from dev/methods/825deccd.svg rename to dev/methods/a79627b9.svg index ad42276c..2beb9d34 100644 --- a/dev/methods/825deccd.svg +++ b/dev/methods/a79627b9.svg @@ -1,57 +1,57 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/a072a720.svg b/dev/methods/b2daf2a0.svg similarity index 95% rename from dev/methods/a072a720.svg rename to dev/methods/b2daf2a0.svg index b33f3967..631882cd 100644 --- a/dev/methods/a072a720.svg +++ b/dev/methods/b2daf2a0.svg @@ -1,145 +1,145 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/0206e490.svg b/dev/methods/ba37fc0d.svg similarity index 97% rename from dev/methods/0206e490.svg rename to dev/methods/ba37fc0d.svg index 57e27d80..ffdc9017 100644 --- a/dev/methods/0206e490.svg +++ b/dev/methods/ba37fc0d.svg @@ -1,59 +1,59 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/5cc9d6ff.svg b/dev/methods/d74f0fc4.svg similarity index 97% rename from dev/methods/5cc9d6ff.svg rename to dev/methods/d74f0fc4.svg index 36499109..f2e037a5 100644 --- a/dev/methods/5cc9d6ff.svg +++ b/dev/methods/d74f0fc4.svg @@ -1,53 +1,53 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/924d789c.svg b/dev/methods/dd25ccee.svg similarity index 97% rename from dev/methods/924d789c.svg rename to dev/methods/dd25ccee.svg index d58ca126..2716a69d 100644 --- a/dev/methods/924d789c.svg +++ b/dev/methods/dd25ccee.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/990f3049.svg b/dev/methods/e3f3e0d7.svg similarity index 97% rename from dev/methods/990f3049.svg rename to dev/methods/e3f3e0d7.svg index 914f985f..26b998fd 100644 --- a/dev/methods/990f3049.svg +++ b/dev/methods/e3f3e0d7.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/index.html b/dev/methods/index.html index 40e64176..96c8bdbe 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.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