最近在看这个包DataDrivenDiffEq,有两个问题
1.对Lorenz系统进行稀疏识别的时候,即便加了噪声,识别出来的参数也是非常准确的,这是为什么?用的回归方法也只是STLSQ
2.用ddprob = DataDrivenProblem(sol)的时候ddprob里面会有一个DX,这个导数是用什么方法算的?和从系统生成的导数几乎一致,加了导数效果也比较好
例子用的是DataDrivenDiffEq首页Home上的
using DataDrivenDiffEq
using ModelingToolkit
using OrdinaryDiffEq
using DataDrivenSparse
using LinearAlgebra
using Random
using Statistics
using Distributions
# Create a test problem
function lorenz(u, p, t)
x, y, z = u
ẋ = 10.0 * (y - x)
ẏ = x * (28.0 - z) - y
ż = x * y - (8 / 3) * z
return [ẋ, ẏ, ż]
end
u0 = [1.0; 0.0; 0.0]
tspan = (0.0, 100.0)
dt = 0.1
prob = ODEProblem(lorenz, u0, tspan)
sol = solve(prob, Tsit5(), saveat = dt)
real_u = sol[:, :]'
NoiseLevel=10;
Random.seed!(0);
NoiseMag=NoiseLevel*std(real_u,dims=1)/100;
Noise=NoiseMag.*rand(Normal(0,1), size(real_u));
sol[:, :] = sol[:, :] .+ Noise'
## Start the automatic discovery
ddprob = DataDrivenProblem(sol)
@variables t x(t) y(t) z(t)
u = [x; y; z]
basis = Basis(polynomial_basis(u, 5), u, iv = t)
opt = STLSQ(exp10.(-5:0.1:-1))
ddsol = solve(ddprob, basis, opt, options = DataDrivenCommonOptions(digits = 1))
system = get_basis(ddsol)
println(get_basis(ddsol))
println(get_parameter_map(system))