-
A macOS / Xcode / Swift CLI wrapping Stan's cmdstan.
-
An experimental port of McElreath's R implementation ulam() in rethinking to Swift.
-
As an "experiment within an experiment", and for me to further my understanding of the mapping back-and-forth between alternate ways of expressing Stan Language Programs, I asked Claude to plan and implement a reverse mapping from a .stan file to an .alist.r file. See sections 2.2 and 5.2 in Docs/UlamManual.md.
Documentation lives in Docs/:
Docs/UserGuide.md— Overview, supported functionality, setup and usage.Docs/UlamManual.md— Ulam pipeline manual (stancode→csv2json→CMDSTAN).Docs/DSLManual.md— Swift+DSL pipeline (alist2dsl→dsl2stan→csv2json→CMDSTAN).Docs/TODO.md— Future work items.CLAUDE.md— Guidance for Claude.
As the last item indicates, the ulam port is being worked on using Claude.
The repository contains ready-to-run input files for several of the models used in the ulam and DSL manuals and also models from "Statistical Rethinking", typically ending with "...m[n][n]", e.g. "milk_m5_7". Those can be found in the top-level Examples/ directory. Each example is a self-contained case directory named after the model:
Examples/<name>/
├── Preliminaries/ the inputs (<name>.csv, <name>.alist.R, and for the DSL cases <Name>.ulam.swift)
└── Results/ empty — the pipeline writes its output here
Once SwiftStan has been installed (see UserGuide.md), to run the examples, copy the contents of the Examples directory into your ~/Documents/<STAN_CASES>/ root and run the pipeline against it. For example:
cd ~/Project/Swift/SwiftStan # Your path to SwiftStan
cp -Rf Examples/* ~/Documents/StanCases/ # Your <Stan_Cases> environment variable
swiftstan ulam --model howell_m4_4