{"_id":"@almostmachines/metropolis-cpd","_rev":"3-7f82364b3125298eef36d631f9178483","name":"@almostmachines/metropolis-cpd","dist-tags":{"latest":"0.1.2"},"versions":{"0.1.0":{"name":"@almostmachines/metropolis-cpd","version":"0.1.0","_id":"@almostmachines/metropolis-cpd@0.1.0","maintainers":[{"name":"jk-almostmachines","email":"jk@almostmachines.dev"}],"dist":{"shasum":"e67c20107d900a929a3cbf3e060ecf0bfaa674b0","tarball":"https://registry.npmjs.org/@almostmachines/metropolis-cpd/-/metropolis-cpd-0.1.0.tgz","fileCount":31,"integrity":"sha512-4NTZ8/1fzwoVUi02FpEtLxQc6DdvEYtu8RzC/CYs258IlBilN0vkS542ncHo34eplX+v7dq8GS4mPXuDAlX/gA==","signatures":[{"sig":"MEQCIBYlPfiQbUop2dpH5Fw7xkLkQoPBV7RP9Gapq61z/0i4AiB3iiGzoCPlcD9WPzjNOoLqDcu/OkE0ABPX44mRUSPgEg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":104721},"type":"module","types":"dist/lib.d.ts","module":"dist/metropolis-cpd.js","exports":{".":{"types":"./dist/lib.d.ts","import":"./dist/metropolis-cpd.js"},"./style.css":"./dist/metropolis-cpd.css"},"gitHead":"9adea1915b796074dbf2b7f6dc5ac965cd4dce05","scripts":{"dev":"vite","lint":"eslint .","test":"npm run test:calculations","build":"tsc -b && vite build","preview":"vite preview","build:lib":"vite build --config vite.config.lib.ts && tsc -p tsconfig.lib.json","test:calculations":"mkdir -p tests/.tmp && npx esbuild src/engine/metropolis.ts --bundle --platform=node --format=cjs --outfile=tests/.tmp/metropolis.cjs && npx esbuild src/state/algorithm-state.ts --bundle --platform=node --format=cjs --outfile=tests/.tmp/algorithm-state.cjs && npx esbuild src/config/sanitize.ts --bundle --platform=node --format=cjs --outfile=tests/.tmp/sanitize.cjs && node --test tests/calculations.test.cjs"},"_npmUser":{"name":"jk-almostmachines","email":"jk@almostmachines.dev"},"_npmVersion":"11.6.1","description":"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.","directories":{},"sideEffects":["*.css"],"_nodeVersion":"24.11.0","dependencies":{},"_hasShrinkwrap":false,"devDependencies":{"vite":"^7.2.4","react":"^19.2.0","three":"^0.182.0","eslint":"^9.39.1","globals":"^16.5.0","react-dom":"^19.2.0","@eslint/js":"^9.39.1","typescript":"~5.9.3","@types/node":"^24.10.1","tailwindcss":"^4.1.18","@types/react":"^19.2.5","@types/three":"^0.182.0","@types/react-dom":"^19.2.3","@react-three/drei":"^10.7.7","@tailwindcss/vite":"^4.1.18","typescript-eslint":"^8.46.4","@react-three/fiber":"^9.5.0","@vitejs/plugin-react":"^5.1.1","eslint-plugin-react-hooks":"^7.0.1","eslint-plugin-react-refresh":"^0.4.24"},"peerDependencies":{"react":"^19.0.0","three":"^0.180.0","react-dom":"^19.0.0","@react-three/drei":"^10.0.0","@react-three/fiber":"^9.0.0"},"_npmOperationalInternal":{"tmp":"tmp/metropolis-cpd_0.1.0_1770973022714_0.3801056156940894","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@almostmachines/metropolis-cpd","version":"0.1.1","_id":"@almostmachines/metropolis-cpd@0.1.1","maintainers":[{"name":"jk-almostmachines","email":"jk@almostmachines.dev"}],"dist":{"shasum":"605789436fefb8e3a9f5141d3389864f8a72161c","tarball":"https://registry.npmjs.org/@almostmachines/metropolis-cpd/-/metropolis-cpd-0.1.1.tgz","fileCount":31,"integrity":"sha512-13XfEpXWUKyhcy24qREDo3Iw7Rnj+5yMbHEb5WnjmOHecbsKnJazinT7FYoUCPEAc+v0/YGX6p1YvMZDExd1Sg==","signatures":[{"sig":"MEUCIQD7l6yDBfY3Gfduk5RNXKZN0Vxy4c9DP5iIJLp7GzT9YwIgU+BypXRFzoreYb1bh3JmHjJk5bUHoQgy8JFgpQ1+l2U=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":104773},"type":"module","types":"dist/lib.d.ts","module":"dist/metropolis-cpd.js","exports":{".":{"types":"./dist/lib.d.ts","import":"./dist/metropolis-cpd.js"},"./style.css":"./dist/metropolis-cpd.css"},"gitHead":"b27383a6f62d59273716ee79b05b60694dbd607d","scripts":{"dev":"vite","lint":"eslint .","test":"npm run test:calculations","build":"tsc -b && vite build","preview":"vite preview","build:lib":"vite build --config vite.config.lib.ts && tsc -p tsconfig.lib.json","test:calculations":"mkdir -p tests/.tmp && npx esbuild src/engine/metropolis.ts --bundle --platform=node --format=cjs --outfile=tests/.tmp/metropolis.cjs && npx esbuild src/state/algorithm-state.ts --bundle --platform=node --format=cjs --outfile=tests/.tmp/algorithm-state.cjs && npx esbuild src/config/sanitize.ts --bundle --platform=node --format=cjs --outfile=tests/.tmp/sanitize.cjs && node --test tests/calculations.test.cjs"},"_npmUser":{"name":"jk-almostmachines","email":"jk@almostmachines.dev"},"_npmVersion":"11.6.1","description":"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.","directories":{},"sideEffects":["*.css"],"_nodeVersion":"24.11.0","dependencies":{},"_hasShrinkwrap":false,"devDependencies":{"vite":"^7.2.4","react":"^19.2.0","three":"^0.182.0","eslint":"^9.39.1","globals":"^16.5.0","react-dom":"^19.2.0","@eslint/js":"^9.39.1","typescript":"~5.9.3","@types/node":"^24.10.1","tailwindcss":"^4.1.18","@types/react":"^19.2.5","@types/three":"^0.182.0","@types/react-dom":"^19.2.3","@react-three/drei":"^10.7.7","@tailwindcss/vite":"^4.1.18","typescript-eslint":"^8.46.4","@react-three/fiber":"^9.5.0","@vitejs/plugin-react":"^5.1.1","eslint-plugin-react-hooks":"^7.0.1","eslint-plugin-react-refresh":"^0.4.24"},"peerDependencies":{"react":"^19.0.0","three":"^0.180.0","react-dom":"^19.0.0","@react-three/drei":"^10.0.0","@react-three/fiber":"^9.0.0"},"_npmOperationalInternal":{"tmp":"tmp/metropolis-cpd_0.1.1_1770974657659_0.8744352063430818","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@almostmachines/metropolis-cpd","version":"0.1.2","type":"module","module":"dist/metropolis-cpd.js","types":"dist/lib.d.ts","exports":{".":{"import":"./dist/metropolis-cpd.js","types":"./dist/lib.d.ts"},"./style.css":"./dist/metropolis-cpd.css"},"sideEffects":["*.css"],"scripts":{"dev":"vite","build":"tsc -b && vite build","build:lib":"vite build --config vite.config.lib.ts && tsc -p tsconfig.lib.json","lint":"eslint .","preview":"vite preview","test":"npm run test:calculations","test:calculations":"mkdir -p tests/.tmp && npx esbuild src/engine/metropolis.ts --bundle --platform=node --format=cjs --outfile=tests/.tmp/metropolis.cjs && npx esbuild src/state/algorithm-state.ts --bundle --platform=node --format=cjs --outfile=tests/.tmp/algorithm-state.cjs && npx esbuild src/config/sanitize.ts --bundle --platform=node --format=cjs --outfile=tests/.tmp/sanitize.cjs && node --test tests/calculations.test.cjs","prepublishOnly":"npm run build:lib"},"peerDependencies":{"@react-three/drei":"^10.0.0","@react-three/fiber":"^9.0.0","react":"^19.0.0","react-dom":"^19.0.0","three":"^0.180.0"},"dependencies":{},"devDependencies":{"@eslint/js":"^9.39.1","@react-three/drei":"^10.7.7","@react-three/fiber":"^9.5.0","@tailwindcss/vite":"^4.1.18","@types/node":"^24.10.1","@types/react":"^19.2.5","@types/react-dom":"^19.2.3","@types/three":"^0.182.0","@vitejs/plugin-react":"^5.1.1","eslint":"^9.39.1","eslint-plugin-react-hooks":"^7.0.1","eslint-plugin-react-refresh":"^0.4.24","globals":"^16.5.0","react":"^19.2.0","react-dom":"^19.2.0","tailwindcss":"^4.1.18","three":"^0.182.0","typescript":"~5.9.3","typescript-eslint":"^8.46.4","vite":"^7.2.4"},"gitHead":"b9c1f5c3a576b9f5d94b3313bac29426264f6581","_id":"@almostmachines/metropolis-cpd@0.1.2","description":"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.","_nodeVersion":"24.11.0","_npmVersion":"11.6.1","dist":{"integrity":"sha512-RC9eiw0CURwLbXtrrok7raya+bEYBE18dgLzukvBPeFCFN0t696PhG1rceS9Cqso8czYs0FWOMpZe/HoCkOBSw==","shasum":"8c41d222b476309b0c521852f0c56ae31c0e63a8","tarball":"https://registry.npmjs.org/@almostmachines/metropolis-cpd/-/metropolis-cpd-0.1.2.tgz","fileCount":31,"unpackedSize":104816,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIA3VoIZpH72fzCK4cXkenytwx+oh1B6Sqd08slo5Q8ekAiBkQdDvCQ5Cw9NuB8zEDVA3sT2CDdSrqdUVpRLIP30Bng=="}]},"_npmUser":{"name":"jk-almostmachines","email":"jk@almostmachines.dev"},"directories":{},"maintainers":[{"name":"jk-almostmachines","email":"jk@almostmachines.dev"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/metropolis-cpd_0.1.2_1770975943583_0.36009806361155583"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-13T08:57:02.598Z","modified":"2026-02-13T09:45:43.852Z","0.1.0":"2026-02-13T08:57:02.851Z","0.1.1":"2026-02-13T09:24:17.810Z","0.1.2":"2026-02-13T09:45:43.731Z"},"description":"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.","maintainers":[{"name":"jk-almostmachines","email":"jk@almostmachines.dev"}],"readme":"# Metropolis Algorithm Change-Point Explorer\n\nAn 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.\n\n## What it does\n\nThe app fits a change-point model with three unknown parameters:\n\n- **τ**: the change time (hours in `[0, 24]`)\n- **μ₁**: mean observation level before the change\n- **μ₂**: mean observation level after the change\n\nObservation noise **sigma is known and fixed** during sampling (but editable in settings).\n\nYou can run the sampler step-by-step:\n\n1. A white proposal point appears with a line to the current state\n2. The control panel shows log posterior ratio and acceptance probability\n3. Click **Accept** to run the Metropolis accept/reject draw\n4. Repeat or switch to full auto mode\n\n**Full Auto** runs batches of steps every animation frame until the target sample count is reached.\n\n## Getting started\n\n```bash\nnpm install\nnpm run dev\n```\n\nOpen http://localhost:5173 in your browser.\n\n## Controls\n\n| Control | Action |\n|---------|--------|\n| **Next Step** | Generate a proposal and display it |\n| **Accept (X%)** | Run the accept/reject decision |\n| **Full Auto** | Run all remaining samples automatically |\n| **Stop** | Pause auto mode |\n| **Reset** | Generate new data and restart from scratch |\n| **Click + drag** | Rotate the 3D view |\n| **Scroll** | Zoom in/out |\n| **Right-click + drag** | Pan |\n\nAll settings are editable while the algorithm is idle.\n\n## 3D scene legend\n\n| Marker | Meaning |\n|--------|---------|\n| Gold octahedron | True values `(τ, μ₁, μ₂)` |\n| Cyan sphere | Current chain position |\n| White sphere + line | Pending proposal |\n| Blue dots | Accepted samples (early) |\n| Purple dots | Accepted samples (late) |\n| Gray dots | Burn-in samples |\n\nThe accepted-sample gradient shows chain progression over time.\n\n## Statistical model\n\n- **Data generation**: `time_i ~ Uniform(0, 24)` and\n  - if `time_i < τ`: `y_i ~ Normal(μ₁, knownSigma)`\n  - else: `y_i ~ Normal(μ₂, knownSigma)`\n- **Likelihood**: product of normal densities, evaluated in log-space\n- **Prior**:\n  - `τ ~ Uniform(0, 24)`\n  - `μ₁ ~ Normal(priorMean₁, priorStd₁)`\n  - `μ₂ ~ Normal(priorMean₂, priorStd₂)`\n- **Proposal**: symmetric normal perturbation with configurable widths for `τ`, `μ₁`, `μ₂`\n- **Acceptance**: `alpha = min(1, exp(log_posterior_proposed - log_posterior_current))`\n\n## Project structure\n\n```text\nsrc/\n  engine/\n    random.ts              # Box-Muller normal sampling\n    data-generator.ts      # Synthetic change-point observations\n    model.ts               # logLikelihood, logPrior, logPosterior\n    metropolis.ts          # propose, acceptanceProbability, step\n\n  state/\n    types.ts               # State shape and actions\n    algorithm-state.ts     # useReducer state machine\n\n  scene/\n    SceneRoot.tsx          # Canvas, camera, lighting, controls\n    PointCloud.tsx         # InstancedMesh sample cloud\n    AxisSystem.tsx         # 3D axes for τ, μ₁, μ₂\n    TrueMode.tsx           # Gold marker at true values\n    CurrentHypothesis.tsx  # Cyan current state marker\n    ProposalPoint.tsx      # White proposal marker + connecting line\n    Legend.tsx             # Scene legend overlay\n\n  ui/\n    ControlPanel.tsx\n    StepControls.tsx\n    ParameterInputs.tsx\n    StatusDisplay.tsx\n    ProgressBar.tsx\n    ResultsDisplay.tsx\n\n  config/\n    sanitize.ts            # Input/config sanitization\n```\n\n## Built with\n\n- [React](https://react.dev) + [TypeScript](https://www.typescriptlang.org) + [Vite](https://vite.dev)\n- [react-three-fiber](https://r3f.docs.pmnd.rs) + [@react-three/drei](https://drei.docs.pmnd.rs)\n- [Tailwind CSS v4](https://tailwindcss.com)\n\n## License\n\n[MIT](LICENSE)\n","readmeFilename":"README.md"}