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

@datagrok-libraries/sci-comp

v0.6.0

Published

Pure TypeScript library for numerical methods

Readme

Sci Comp

Pure TypeScript library of numerical methods for the Datagrok platform.

Modules

  • Optimization:

    • single-objective (detailed docs):
      • Nelder-Mead - derivative-free simplex method
      • PSO (Particle Swarm Optimization) - stochastic population-based method
      • Gradient Descent - first-order method with numerical gradients, momentum, and learning rate decay
      • Adam - adaptive moment estimation with per-parameter learning rates
      • L-BFGS - limited-memory quasi-Newton method with two-loop recursion and Armijo line search
      • L-BFGS-B - limited-memory BFGS with native box constraints, Moré–Thuente strong-Wolfe line search, compact representation, and Morales–Nocedal 2011 subspace refinement
    • multi-objective:
  • Time Series:

    • extraction of 45 features per value column (statistics, trend, complexity, threshold-based metrics)
  • Statistics (detailed docs):

  • NCA (Non-Compartmental Analysis):

    • 8 PK parameters: Cmax, Tmax, AUClast, AUCinf, %AUCextrap, λz, t½, CL, Vz
    • 3 AUC methods (linear, log-linear, linear-up/log-down) × naive Float64 + Neumaier-compensated summation
    • 4 BLQ-handling rules × 4 phases
    • λz auto best-fit (subset search by adjusted R²) + manual
    • IV bolus c0 back-extrapolation (logslope / c1 / cmin / set0 chain), extravascular pre-dose insertion
    • validated against PKNCA on 26 reference profiles (theophylline, indomethacin, synthetic rat)

Installation

npm install @datagrok-libraries/sci-comp

Quick start

Optimization

Minimize the Rosenbrock function with Nelder-Mead:

import {singleObjective} from '@datagrok-libraries/sci-comp';

const rosenbrock = (x: Float64Array): number => {
  let sum = 0;
  for (let i = 0; i < x.length - 1; i++)
    sum += 100 * (x[i + 1] - x[i] ** 2) ** 2 + (1 - x[i]) ** 2;
  return sum;
};

const nm = new singleObjective.NelderMead();
const result = nm.minimize(rosenbrock, new Float64Array([-1.2, 1.0]), {
  maxIterations: 5_000,
  tolerance: 1e-12,
});
// result.point ≈ [1, 1], result.value ≈ 0

See single-objective optimization docs for

  • constrained optimization
  • implemented methods
  • sync and async objectives
  • callbacks
  • registry
  • benchmarks
  • examples

Time-series feature extraction

Extract tsfresh-compatible features from time-series data:

import {timeSeries} from '@datagrok-libraries/sci-comp';

const df: timeSeries.featureExtraction.TimeSeriesDataFrame = {
  ids: new Uint32Array([1, 1, 1, 1, 1]),
  time: new Float64Array([0, 1, 2, 3, 4]),
  rowCount: 5,
  columns: [{
    name: 'temperature',
    data: new Float64Array([20.1, 20.5, 21.0, 20.8, 21.3]),
  }],
};

const result = timeSeries.featureExtraction.extractFeatures(df);
// result.nSamples = 1, result.columns.length = 45
// e.g. temperature__mean, temperature__standard_deviation, temperature__linear_trend__attr_slope, ...

See feature extraction docs for

  • full feature list (45 features across 11 categories)
  • input/output format
  • multiple samples and multiple columns
  • validation
  • naming convention
  • examples

Statistics

Run Welch's t-test on two samples with NaN handling:

import {stats} from '@datagrok-libraries/sci-comp';

const a = [69, 70, 66, 63, 68, 70, 69, 67, 62, 63];
const b = [68, 62, 67, 68, 69, 67, 61, 59, 62, 61];

const r = stats.welchTTest(a, b);
// r.statistic ≈ 1.511, r.pValue ≈ 0.149

Or compare each treated group to a control with Dunnett's family-wise-error-controlled test:

const control = [7.40, 8.50, 7.20, 8.24, 9.84, 8.32];
const treated = [
  {doseLevel: 1, values: [9.76, 8.80, 7.68, 9.36]},
  {doseLevel: 2, values: [12.80, 9.68, 12.16, 9.20, 10.55]},
];

const dun = stats.dunnettPairwise(control, treated);
// dun[1].pValueAdj ≈ 0.0058  → drug B differs from control at α = 0.05

See statistics docs for

  • full method list (14 tests across 8 domains)
  • input types (number[], Float32Array, Float64Array, Int32Array, …)
  • NaN handling (NaN as missing-value sentinel, stripped per-method)
  • worked examples reproducing published references (Dunnett 1955, NIST Iris, Williams 1971/1972, Young 1985, Montgomery 15.10 vs SAS PROC GLM)
  • validation against scipy via JSON fixtures (179 cases, 14 fixture files)

NCA

Run the full Non-Compartmental Analysis pipeline on one PK profile:

import {nca} from '@datagrok-libraries/sci-comp';

const inputs: nca.ProfileInputs = {
  time:    new Float64Array([0, 0.25, 0.5, 1, 2, 4, 8, 12]),
  conc:    new Float64Array([0, 1.5,  2.4, 3.0, 1.8, 0.9, 0.3, 0.1]),
  blqMask: new Uint8Array(8),
  lloq:    0.05,
  dose:               2.5,
  doseUnits:          'mg',
  concentrationUnits: 'mg/L',
  timeUnits:          'h',
  route:              nca.ROUTE_PO,
  infusionDuration:   null,
  bodyWeight:         null,
};

const rules: nca.NcaRules = {
  aucMethod: 'linear-up-log-down',
  blq: {
    preFirstMeasurable: 'set-zero', embedded: 'set-zero',
    afterLast: 'set-zero', consecutiveAfterLast: 'set-zero',
  },
  lambdaZ: {
    mode: 'auto-best-fit',
    minPoints: 3, minRSquared: 0.85, excludeCmax: true,
    adjRSquaredFactor: 1e-4,
  },
  extrapWarnPct: 20, extrapErrorPct: 50,
  compensatedSummation: false,
};

const result = nca.computeNca(inputs, rules);
// result.values: Cmax, Tmax, AUClast, AUCinf, lambdaZ, halfLife, cl, vz, pctExtrap
// result.provenance: lambda_z fit details, BLQ trace, AUC method, warnings
// result.status: 'ok' | 'partial' | 'failed'

See NCA docs for

  • algorithm details (BLQ phasing, lambda_z best-fit search, IV bolus c0 back-extrapolation)
  • parameter contract (ProfileInputs, NcaRules, ComputeResult)
  • validation against fixtures (26 profiles across 3 datasets, all within §9.2 tolerances)