I would like to request some help from the data science community.
My task with machine learning is do achieve the following in pyTorch
:
I have an equation given by:
$$ \frac{\mathrm{d} s}{\mathrm{d} t}=4a−2s+\lambda(s) $$
Where $a$ is an input constant and $\lambda$ is a non-linear term that depends on $s$.
I know that the true solution for $\lambda\left(s\right)$ is $\sin \left( s\right) \cos\left(s\right)$
I have generated data from [0, 5]s with the true solution and with the equation excluding the non-linear term for a range of initial conditions and a range of $a$'s.
import numpy as np
import pandas as pd
from scipy.integrate import solve_ivp
def foo_true(t, s, a):
ds_dt = 4*a -2*s + np.sin(s)*np.cos(s)
return ds_dt
def foo(t, s, a):
ds_dt = 4*a -2*s
return ds_dt
# Settings:
t = np.linspace(0, 5, 1000)
a_s = np.arange(1, 10)
s0_s = np.arange(1, 10)
# Store the data
df_true = pd.DataFrame({'time': t})
df = pd.DataFrame({'time': t})
# Generate the data
for a in a_s:
for s0 in s0_s:
sol_true = solve_ivp(foo_true, (t[0], t[-1]), (s0,), t_eval=t, args=(a,))
df_true[f'{a}_{s0}'] = sol_true.y.T
for a in a_s:
for s0 in s0_s:
sol = solve_ivp(foo, (t[0], t[-1]), (s0,), t_eval=t, args=(a,))
df[f'{a}_{s0}'] = sol.y.T
In the above code, df_true
is a data frame containing the true dynamics of the system and df
the dynamics with a discrepancy.
The figure bellow shows the an example in discrepancy of the data:
Given that I know part of the physics, how can I model $\lambda$?
Does anyone know of a paper/repo with a conceptually similar example that I can a look into?
Best regards
df_true
and with some discrepancydf
for a range of initial conditions and variations of $a$. I would like to use ML to infer a correction term between the data indf
anddf_true
. $\endgroup$