npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@geodetic-lse/core

v2.0.0

Published

Core library for Geodetic LSE

Readme

@geodetic-lse/core

Generic linear least squares solver with internal reliability analysis, based on the method of parametric adjustment (indirect observations).

npm version npm downloads License: MPL-2.0 TypeScript

Installation

npm install @geodetic-lse/core

Overview

This package provides the mathematical core of the Geodetic LSE engine:

  • Normal equations solver — using LU decomposition for numerical stability
  • Reliability analysis — Baarda's normalized residuals, local redundancy numbers, and estimated gross errors

It is designed to be discipline-agnostic: any problem that can be expressed as A·dx + v = dl can use this solver.

API

solveLeastSquares(A, P, l, fx, x)

Solves the weighted least squares system using the normal equations method.

| Parameter | Type | Description | | --------- | -------- | ------------------------------------------------ | | A | Matrix | Design matrix (m × n) | | P | Matrix | Weight matrix (m × m), diagonal | | l | Matrix | Observation vector (m × 1) | | fx | Matrix | Computed values at initial approximation (m × 1) | | x | Matrix | Initial approximation of unknowns (n × 1) |

Returns a LeastSquaresResult:

| Field | Type | Description | | ------------ | -------- | ------------------------------- | | x | Matrix | Adjusted parameters (n × 1) | | v | Matrix | Residuals (m × 1) | | N | Matrix | Normal matrix AᵀPA (n × n) | | Qxx | Matrix | Cofactor matrix N⁻¹ (n × n) | | s0 | number | A posteriori standard deviation | | redundancy | number | Degrees of freedom (m - n) |


computeReliability(sigma0, Qll, P, A, result, alpha?, beta?)

Computes internal and external reliability indicators following Baarda's theory.

| Parameter | Type | Default | Description | | --------- | -------------------- | ------- | --------------------------------------- | | sigma0 | number | | A priori standard deviation | | Qll | Matrix | | Cofactor matrix of observations (m × m) | | P | Matrix | | Weight matrix (m × m) | | A | Matrix | | Design matrix (m × n) | | result | LeastSquaresResult | | Output of solveLeastSquares | | alpha | number | 0.01 | Significance level (type I error rate) | | beta | number | 0.05 | Type II error rate |

Returns a ReliabilityResult:

| Field | Type | Description | | -------- | -------- | ------------------------------------------------------------------------------------------------------------------- | | Qvv | Matrix | Cofactor matrix of residuals (m × m) | | w | Matrix | Normalized residuals — Baarda's wᵢ = vᵢ / (σ₀·√qvvᵢᵢ) (m × 1) | | z | Matrix | Local redundancy numbers rᵢ = qvvᵢᵢ / qllᵢᵢ, ∑rᵢ = redundancy (m × 1) | | g | Matrix | Estimated gross errors gᵢ = −vᵢ / rᵢ; NaN when rᵢ ≈ 0 (m × 1) | | nablaL | Matrix | Internal reliability ∇lᵢ = δ₀·σ₀·√qllᵢᵢ / √rᵢ — min detectable bias; NaN when rᵢ ≈ 0 (m × 1) | | nablaX | Matrix | External reliability ∇xᵢ = Qxx·Aᵀ·P·eᵢ·∇lᵢ — effect on unknowns per observation; NaN column when ∇lᵢ is NaN (n × m) |


solveAndAnalyze(A, P, l, fx, x, sigma0, Qll)

Convenience wrapper that calls solveLeastSquares then computeReliability with default alpha = 0.01 and beta = 0.05, and returns a merged result object containing all fields from both LeastSquaresResult and ReliabilityResult.

Usage

import { matrix } from 'mathjs'
import { solveLeastSquares, computeReliability } from '@geodetic-lse/core'

// Design matrix, weight matrix, observations, computed values, initial unknowns
const A = matrix([
    [1, 0],
    [0, 1],
    [1, -1],
])
const P = matrix([
    [1, 0, 0],
    [0, 1, 0],
    [0, 0, 1],
])
const l = matrix([[10.01], [20.03], [-10.02]])
const fx = matrix([[10.0], [20.0], [-10.0]])
const x0 = matrix([[10.0], [20.0]])

const result = solveLeastSquares(A, P, l, fx, x0)

console.log('Adjusted parameters:', result.x.toArray())
console.log('Residuals:', result.v.toArray())
console.log('s0:', result.s0)

Mathematical model

The functional model is:

A·dx + v = dl     where  dl = l − f(x₀)

The normal equations are formed and solved via LU decomposition (Doolittle / lup):

N·dx = AᵀP·dl     where  N = AᵀPA
Qxx  = N⁻¹
s0   = sqrt(vᵀPv / r)

An ill-conditioning guard is applied: if the 1-norm condition number κ₁(N) exceeds 10¹², an error is thrown.

Reliability

Internal and external reliability follow Baarda's theory. The non-centrality parameter δ₀ is derived from the chosen significance level α (type I error) and power 1−β (type II error):

δ₀ = Φ⁻¹(1 − α/2) − Φ⁻¹(β)

where Φ⁻¹ is the inverse standard normal CDF. With defaults α = 0.01 and β = 0.05:

Internal reliability:  ∇lᵢ = δ₀·σ₀·√qllᵢᵢ / √rᵢ   (min detectable bias on obs i)
External reliability:  ∇xᵢ = Qxx·Aᵀ·P·eᵢ·∇lᵢ       (effect on unknowns, n×1 per obs i)

∇lᵢ and the i-th column of ∇xᵢ are NaN when rᵢ ≈ 0 (observation has no redundancy).

License

MPL-2.0