Skip to content

Conversation

@pavelkomarov
Copy link
Collaborator

@pavelkomarov pavelkomarov commented Aug 23, 2025

Just needed the integration utility to handle variable dt, really, and scipy's function already does, because they're awesome.

dxdt_hat[0] = x_hat[1] - x_hat[0]
dxdt_hat[-1] = x_hat[-1] - x_hat[-2] # use first-order endpoint formulas so as not to amplify noise. See #104

x_hat = utility.integrate_dxdt_hat(dxdt_hat, dt=1) # estimate new x_hat by integrating derivative
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed the name of this thing, so kwarg breaks.

t = _t

# The below does the approximate equivalent of this code, but sparsely in O(N sigma), since the rbf falls off rapidly
# The below does the approximate equivalent of this code, but sparsely in O(N sigma^2), since the rbf falls off rapidly
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solving a sparse linear system with $d$ elements per row is $O(Nd^2)$.

:return: **x_hat** (np.array[float]) -- integral of dxdt_hat
"""
return np.hstack((0, scipy.integrate.cumulative_trapezoid(dxdt_hat)))*dt
return cumulative_trapezoid(dxdt_hat, initial=0)*_t if np.isscalar(_t) \
Copy link
Collaborator Author

@pavelkomarov pavelkomarov Aug 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out cumulative_trapezoid can also take an initial value, in which case it returns a result the same length as the thing it's integrating, so there is no need to call hstack.

@pavelkomarov
Copy link
Collaborator Author

pavelkomarov commented Aug 24, 2025

No idea why the optimize test I added is causing the build to take many times longer than usual (I canceled after 15 minutes one time and 6 another, and it usually takes under 2). That test takes about 30 seconds locally and passes fine. Chat thinks it could be a random number generator blocking, waiting for entropy? But the 15 minute run was from before I added seeding in the test.

@pavelkomarov pavelkomarov merged commit e03f5f8 into master Aug 24, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants