@mcmcjs/stan 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Shravan Goswami
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # @mcmcjs/stan
2
+
3
+ The native Stan engine for [MCMC.js](https://github.com/mcmcjs/mcmcjs).
4
+
5
+ It resolves a local [CmdStan](https://mc-stan.org/docs/cmdstan-guide/) install, compiles Stan models through CmdStan's make with content-hash caching, and runs NUTS with one process per chain, streaming per-chain progress and draw batches.
6
+
7
+ ## What it provides
8
+
9
+ - `stanEngine`: the engine descriptor with a `doctor` that reports CmdStan, stanc, make, and the C++ compiler.
10
+ - `runFit(spec, install, io)`: one inference run producing the standard samples file and run record, with `onProgress`/`onDraws` streaming and `AbortSignal` cancellation.
11
+ - `runPredict(spec, install, io)`: posterior prediction via CmdStan `generate_quantities`, replaying a samples file through the model's generated quantities block; `[predict].targets` selects which generated variables to keep.
12
+ - `runMatrix(spec, versions, io)`: the same fit across several installed CmdStan versions, one entry per version (backs `mcmc fit --versions`).
13
+ - `resolveCmdStan(version?)`: finds a CmdStan install; an explicit `MCMCJS_CMDSTAN`/`CMDSTAN` home wins, then the managed root, then `~/.cmdstan` shared with other Stan interfaces.
14
+ - `runSetup(options)`: provisions CmdStan from the official release tarball into the managed root and builds it once.
15
+ - `listVersions()` / `addVersion(version)` / `removeVersion(version)`: manage CmdStan installs under the managed root (backs `mcmc stan version`).
16
+ - `compileModel(install, modelPath)`: the cached model compile, reusable on its own.
17
+
18
+ ## How a fit runs
19
+
20
+ The spec's canonical data is written to a temp `data.json` (the same JSON a Stan data block reads), one CmdStan process per chain samples with a shared seed and per-chain `id`, progress is parsed from CmdStan's iteration lines, and draws stream by tailing the growing CSVs.
21
+ When all chains finish, the CSVs are combined into the MCMC.js samples format via `@mcmcjs/core`.
22
+
23
+ ## Requirements
24
+
25
+ CmdStan compiles models with the system toolchain: GNU make and a C++ compiler (g++ or clang++) must be installed.
26
+ `mcmc setup --engine stan` handles the CmdStan side; the compiler comes from your system package manager.
27
+
28
+ ## License
29
+
30
+ MIT