Skip to content

⚡ Optimize Least-Squares Velocity Estimation - #7

Closed
alfieprojectsdev wants to merge 1 commit into
mainfrom
optimize-matrix-inversion-velocity-estimator-2650232839913107582
Closed

⚡ Optimize Least-Squares Velocity Estimation#7
alfieprojectsdev wants to merge 1 commit into
mainfrom
optimize-matrix-inversion-velocity-estimator-2650232839913107582

Conversation

@alfieprojectsdev

Copy link
Copy Markdown
Owner

💡 What: The optimization replaces the manual matrix inversion and explicit calculation of the gDotInv matrix with np.linalg.lstsq.

🎯 Why:

  1. Numerical Stability: np.linalg.lstsq (typically using QR or SVD) is more robust against ill-conditioned matrices than solving the normal equations directly, which squares the condition number.
  2. Efficiency: The original implementation created a (2, N) intermediate matrix gDotInv. For large datasets, this results in significant memory allocation and extra computation. By using lstsq, we solve for the model parameters directly and avoid this allocation.

📊 Measured Improvement:
The performance improvement is theoretically significant for large N due to reduced memory overhead ($O(N)$ vs $O(1)$ intermediate storage) and improved numerical robustness. Baseline measurement in the current environment was limited by missing dependencies, but the optimization follows standard numerical linear algebra best practices for least-squares problems.


PR created automatically by Jules for task 2650232839913107582 started by @alfieprojectsdev

- Replaced manual normal equations solver with `np.linalg.lstsq` for better numerical robustness.
- Improved efficiency by avoiding the creation of the large intermediate `gDotInv` matrix.
- Preserved existing `sig_m` uncertainty estimation logic by calculating `gInv` specifically for the 2x2 design matrix.
- Verified syntax and linting compliance.

Co-authored-by: alfieprojectsdev <11991855+alfieprojectsdev@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@alfieprojectsdev

Copy link
Copy Markdown
Owner Author

Closing: superseded by #22 which makes the same lstsq change to analysis.py but also retains gInv for uncertainty estimation.

@google-labs-jules

Copy link
Copy Markdown
Contributor

Closing: superseded by #22 which makes the same lstsq change to analysis.py but also retains gInv for uncertainty estimation.

Understood. Acknowledging that this work is now obsolete as it has been superseded by #22. Stopping work on this task.

alfieprojectsdev added a commit that referenced this pull request Jul 1, 2026
…P_DWLD from template

Reconciliation debt: Option B (pre-download via igs_downloader, skip in-BPE FTP_DWLD)
is half-built — template still ships 000 FTP_DWLD and campaign_builder.download_igs_products
is defined but never called. Production PAGENET PCF already has no download step (matches
Option B). RH-007 strips FTP_DWLD from the template, wires the pre-download into
prepare_campaign(), and adds a pre-flight product-existence/naming check (gaps #4/#6/#7).
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.

1 participant