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

@almostmachines/metropolis-cpd

v0.1.2

Published

An interactive 3D visualization of the Metropolis algorithm applied to Bayesian change-point detection. The app estimates when a process changed over a 24-hour period, plus the mean level before and after the change.

Readme

Metropolis Algorithm Change-Point Explorer

An interactive 3D visualization of the Metropolis algorithm applied to Bayesian change-point detection. The app estimates when a process changed over a 24-hour period, plus the mean level before and after the change.

What it does

The app fits a change-point model with three unknown parameters:

  • τ: the change time (hours in [0, 24])
  • μ₁: mean observation level before the change
  • μ₂: mean observation level after the change

Observation noise sigma is known and fixed during sampling (but editable in settings).

You can run the sampler step-by-step:

  1. A white proposal point appears with a line to the current state
  2. The control panel shows log posterior ratio and acceptance probability
  3. Click Accept to run the Metropolis accept/reject draw
  4. Repeat or switch to full auto mode

Full Auto runs batches of steps every animation frame until the target sample count is reached.

Getting started

npm install
npm run dev

Open http://localhost:5173 in your browser.

Controls

| Control | Action | |---------|--------| | Next Step | Generate a proposal and display it | | Accept (X%) | Run the accept/reject decision | | Full Auto | Run all remaining samples automatically | | Stop | Pause auto mode | | Reset | Generate new data and restart from scratch | | Click + drag | Rotate the 3D view | | Scroll | Zoom in/out | | Right-click + drag | Pan |

All settings are editable while the algorithm is idle.

3D scene legend

| Marker | Meaning | |--------|---------| | Gold octahedron | True values (τ, μ₁, μ₂) | | Cyan sphere | Current chain position | | White sphere + line | Pending proposal | | Blue dots | Accepted samples (early) | | Purple dots | Accepted samples (late) | | Gray dots | Burn-in samples |

The accepted-sample gradient shows chain progression over time.

Statistical model

  • Data generation: time_i ~ Uniform(0, 24) and
    • if time_i < τ: y_i ~ Normal(μ₁, knownSigma)
    • else: y_i ~ Normal(μ₂, knownSigma)
  • Likelihood: product of normal densities, evaluated in log-space
  • Prior:
    • τ ~ Uniform(0, 24)
    • μ₁ ~ Normal(priorMean₁, priorStd₁)
    • μ₂ ~ Normal(priorMean₂, priorStd₂)
  • Proposal: symmetric normal perturbation with configurable widths for τ, μ₁, μ₂
  • Acceptance: alpha = min(1, exp(log_posterior_proposed - log_posterior_current))

Project structure

src/
  engine/
    random.ts              # Box-Muller normal sampling
    data-generator.ts      # Synthetic change-point observations
    model.ts               # logLikelihood, logPrior, logPosterior
    metropolis.ts          # propose, acceptanceProbability, step

  state/
    types.ts               # State shape and actions
    algorithm-state.ts     # useReducer state machine

  scene/
    SceneRoot.tsx          # Canvas, camera, lighting, controls
    PointCloud.tsx         # InstancedMesh sample cloud
    AxisSystem.tsx         # 3D axes for τ, μ₁, μ₂
    TrueMode.tsx           # Gold marker at true values
    CurrentHypothesis.tsx  # Cyan current state marker
    ProposalPoint.tsx      # White proposal marker + connecting line
    Legend.tsx             # Scene legend overlay

  ui/
    ControlPanel.tsx
    StepControls.tsx
    ParameterInputs.tsx
    StatusDisplay.tsx
    ProgressBar.tsx
    ResultsDisplay.tsx

  config/
    sanitize.ts            # Input/config sanitization

Built with

License

MIT