Computed software examples

Checked synthetic demonstrations from released packages and public pre-alpha op_infer.

The first five examples use released versions of OP System, OP Engine, trade-study and VBPCApy. The sixth is an imported, commit-pinned artifact from public pre-alpha op_infer; it does not imply a package release. A final section shows design and verification examples for OP System and OP Engine. All data are synthetic. The plots show computations rather than findings from an application study; their captions state the assumptions and what is checked.

Python source · Numerical inputs and outputs · Versions and artifact hashes · Build notes

Artifact versions: op-system 0.10.0, op-engine 0.9.0, trade-study 0.6.0, vbpca-py 0.5.0, numpy 2.5.4, matplotlib 3.11.2. These are the versions used to generate the displayed artifacts; current releases may be newer.

Spatial diffusion

OP System compiles a named-axis expression for a periodic diffusion stencil; OP Engine integrates the resulting field with fourth-order Runge–Kutta (RK4). The stencil is supplied explicitly on 64 equally spaced cells. Faster spatial variation fades sooner than slower variation.

A 64-cell periodic diffusion field and profiles at four times, computed from an OP System specification with RK4 integration in OP Engine. Spatial discretization is supplied explicitly; all inputs are synthetic.
A periodic spatial field at 121 output times and four selected profiles. The spatial mean is conserved.

The code checks the full trajectory against the exact Fourier-mode solution of the discrete spatial stencil, with a maximum absolute difference below 2e-10. This measures temporal integration error for the chosen grid. It does not measure error against a continuum PDE or establish accuracy for other spatial discretizations.

SVG · PDF

Stochastic transfers

OP Engine runs 512 independent realizations of a two-state transfer process using the exact stochastic simulation algorithm (SSA), with one event clock per run. Each starts with 40 units; each remaining unit transfers at rate 0.6. The example retains the accepted firing counts and checks conservation and the correspondence between counts and transferred units.

512 independent exact stochastic transfer simulations, their empirical mean and pointwise 5th–95th percentile range, and the final distribution alongside analytic mean and binomial references. Synthetic demonstration.
Individual paths vary. The reference mean and final binomial distribution are known for this transfer process. The shaded range is pointwise variability across runs, not uncertainty in the estimated mean.

SVG · PDF

Replicated designs

trade-study evaluates ten sample-mean designs using 512 paired replicates. The measurement standard deviation is either 1 or 1.5. The noisier measurement is assigned a lower cost; the standard measurement has a fixed setup cost. Those costs are illustrative assumptions. The circles mark designs for which no alternative improves both mean error and assumed cost.

Ten synthetic sample-mean designs compared across 512 paired replicates. Nondominated mean error and assumed cost are marked, and empirical errors are compared with analytic variances. Costs are declared assumptions, not measured field costs.
Increasing the sample count reduces estimation error in this toy problem. The right panel compares the Monte Carlo estimates with the known variance of a sample mean.

The table reads the same generated data as the figure. Error estimates depend on these 512 simulated replicates. A design is nondominated when no other design is at least as good on both stated objectives and better on at least one. Choosing a design for an application also requires preferences or constraints relevant to that application.

On smaller screens, scroll the table to see cost and nondominance.

Ten synthetic designs, 512 paired replicates each. Lower error and cost are preferred. Bars use a separate linear scale in each column.
Samples Measurement SD Mean squared error Assumed cost Nondominated
8 1.0 0.137 16.0 Yes
8 1.5 0.308 4.4 Yes
16 1.0 0.065 24.0 No
16 1.5 0.146 8.8 Yes
32 1.0 0.029 40.0 Yes
32 1.5 0.064 17.6 Yes
64 1.0 0.015 72.0 Yes
64 1.5 0.034 35.2 Yes
128 1.0 0.008 136.0 Yes
128 1.5 0.019 70.4 Yes

CSV table · SVG · PDF

Incomplete data

VBPCApy fits a two-component model to observed entries of a noisy synthetic matrix. Roughly 35% of entries are withheld, shown in gray. The generating signal uses two patterns; that choice is supplied to the fitted model.

A synthetic two-pattern signal, noisy observed entries with unobserved cells in gray, and a VBPCA reconstruction. Held-out observations are excluded from fitting. This illustration does not establish rank selection or uncertainty calibration.
Left: generating signal. Middle: available noisy observations. Right: fitted reconstruction. All panels share a color scale.

The root mean squared reconstruction error on withheld noisy observations is about 0.22 for this seeded example; the generating noise standard deviation is 0.2. This is one reconstruction check with a known component count. Choosing the rank and assessing uncertainty calibration require separate studies.

SVG · PDF

Archetypes from incomplete categorical data

This example follows the steps of the 2024 cultural-transmission paper on synthetic data. Each of 150 samples is a mixture of three archetypes, drawn from Dirichlet weights, and has 24 categorical variables with three levels; about 30% of the variables are unobserved. VBPCApy’s MissingAwareOneHotEncoder codes each variable as indicator columns and leaves an unobserved variable missing rather than setting it to zero. A two-component VBPCA model is fitted to the observed indicators, and archetypal analysis (Mørup and Hansen 2012) is applied to its reconstruction.

Three panels. The first shows the one-hot encoded data for 60 samples with unobserved variables marked. The second shows recovered archetype memberships in a triangle, coloured by each sample's dominant generating archetype. The third shows recovered against generating memberships, close to the line of equality.
Left: missing-aware one-hot encoding of the first 60 samples; unobserved variables are marked. Middle: archetype memberships recovered from the VBPCA reconstruction, in a triangle whose corners are the three archetypes. Right: recovered against generating memberships.

The recovered memberships correlate with the generating memberships at 0.89, 0.92 and 0.89 for the three archetypes, with mean absolute error 0.10. With every variable observed, the same analysis gives 0.94, 0.95 and 0.94, so the missing entries cost some precision. Recovery is also limited by drawing one level per variable. The numbers of components and archetypes are supplied; choosing them requires separate checks. The archetypal analysis is written in the script, because the py_pcha release used in the paper does not run under NumPy 2.

SVG · PDF

Inference calibration

op_infer evaluates one Normal-model fixture for which the posterior density is available analytically. The left panel compares 1,024 seeded draws from that fixture with the exact posterior density. The right panel summarizes randomized-rank probability-integral-transform values from 64 simulation-based calibration (SBC) replicates.

An exact Normal posterior density overlaid on 1,024 analytic-fixture draws, beside a histogram of randomized-rank PIT values from 64 SBC replicates.
A checked analytic fixture and an intentionally small SBC bank. Sixty-four replicates are underpowered and are not evidence that inference is calibrated.

The fixture completed all 64 requested replicates without a failed attempt. Its recorded gate label is underpowered pass: the implementation and accounting checks passed, but the replicate count is below the prespecified power floor. The histogram is therefore a software demonstration, not a calibration certificate or application result.

Retained data · Summary · Upstream manifest · Pinned source identity · SVG · PDF

OP stack design and verification

These examples show design choices of OP System and OP Engine on synthetic models, each with an independent check. They use released OP System 0.10.0 and OP Engine 0.9.1 with JAX and CPU PyTorch. Every figure reports software behavior within the packages’ documented scope, not a finding about a study system. The research page compares the stack with related tools.

Python source and pinned dependencies · Numerical inputs and outputs · Versions and artifact hashes · Build notes

The array library is chosen at call time. OP System compiles a validated, declarative description (equations or hazard-style transitions, with named axes for groups, space and traits) into one evaluator. The array library is selected from the inputs, so the same compiled model runs under NumPy, under JAX and, within the documented qualified scope, under PyTorch. The numerical method does not change with the namespace.

Two-panel synthetic chemostat example comparing trajectories with an adaptive reference and showing final errors under NumPy, JAX and PyTorch at two precisions. Details follow.
One compiled model under three array libraries. (a) A six-state nutrient, producer and grazer chemostat written as hazard-style transitions, compiled once and integrated with fixed-step fourth-order Runge-Kutta through OP Engine; open markers are an adaptive high-order reference (SciPy DOP853, relative tolerance 10−12). (b) Error at the final time against that reference. Because the same method performs the same arithmetic in each namespace, eager evaluation under NumPy, JAX and PyTorch is bit-identical at each precision in this run (1.26 × 10−8 in float64, 4.63 × 10−6 in float32), and the code asserts that equality. Traced once under jax.jit, which may fuse and reorder operations, the float64 error differs from the eager value only at the 10−15 level. The dotted and dash-dot lines are machine epsilon for each precision, drawn as references; the error of a 400-step integration is well above epsilon, as expected. Synthetic model, assumed parameters. Figure downloads, data and source.

Model authors can check a compiled model. OP System’s qualification report compares a compiled right-hand side with equations the author writes independently, under each array library and precision, and records optional balance checks with their stated conditions.

Two panels. Panel a shows the largest relative disagreement between a compiled age-by-place model and independently written equations under NumPy, JAX and PyTorch, near ten to the minus fifteen in float64 and a few times ten to the minus six in float32. Panel b shows that a copy with a transposed contact matrix passes the population balance check but fails the comparison with independent equations. Details follow.
Checking a compiled model against independently written equations. A susceptible-infectious-recovered model with three age groups in four places, with an asymmetric contact matrix for mixing within each place and movement between places, is compiled once from a configuration specification. OP System's qualification report compares the compiled right-hand side with the same model written cell by cell in plain Python at three test states, in the flat and structured layouts. (a) The largest relative disagreement under NumPy, JAX and PyTorch is between 2 × 10−15 and 1 × 10−14 in float64 and between 7 × 10−7 and 5 × 10−6 in float32, within the report's relative tolerances of 10−7 and 10−5. (b) The same checks on a copy whose contact matrix is indexed the wrong way round. Every population total is still conserved, so the balance check passes (residual 3 × 10−14); the comparison with independent equations fails, with relative disagreement between 0.17 and 16. Agreement at selected states is not a proof for all parameter values, and the check does not assess the accuracy of a time integrator. Synthetic model, assumed parameters. Figure downloads, data and source.

A model written for one run can be batched or differentiated. The same compiled evaluator can be mapped over a parameter grid or differentiated with respect to a parameter without being rewritten.

Two-panel synthetic chemostat ensemble showing a two-parameter grid of final producer values and the median and percentile band over time. Details follow.
A parameter ensemble by jax.vmap over the same compiled evaluator. (a) Producer concentration at the final time over a 45 × 45 grid of two parameters (producer growth rate and inflow nutrient), from one vectorized call; the marker is the nominal pair. (b) The 2025 members over time: median and 5th to 95th percentile band, with a separately computed eager NumPy run at the nominal parameters overlaid. A vectorized JAX evaluation at the nominal pair agrees with that NumPy run to within 10−9 maximum absolute difference. No timing is shown; single-call wall-clock values are recorded in the data file with the CPU model for the record only, since single calls without repetitions are not a benchmark. Synthetic model, assumed parameters. Figure downloads, data and source.
Two-panel derivative check showing a model output with its local autodiff tangent, and finite-difference disagreement against step size. Details follow.
Differentiating a model output through the fixed-step solver. (a) Producer concentration at the final time as a function of the producer growth-rate parameter, with the local tangent at the nominal value from jax.grad through 400 fixed Runge-Kutta steps over the compiled evaluator. (b) Central finite differences of the same discrete 400-step calculation approach the autodiff derivative with slope 2 as the step shrinks, reaching 1.3 × 10−10 relative disagreement before round-off dominates. This checks the derivative of the discrete solver, not continuous-time sensitivity, and it covers the engine's fixed-step methods; the adaptive step controller is not a traced path, as the package documentation states. Figure downloads, data and source.

One specification, several solvers. OP Engine takes compiled models into explicit and adaptive ordinary-differential-equation methods, operator-split and implicit schemes for partial differential equations, exact stochastic simulation with retained event counts, tau-leaping and steady-state solves. The compiler publishes interface contracts, and the engine owns time integration; the user supplies any spatial discretization.

Two-panel synthetic SIRS example comparing deterministic prevalence with 256 direct-SSA paths and showing mean cumulative event counts. Details follow.
One transition specification, two solvers. A susceptible-infectious-recovered model with waning immunity (400 hosts) is written once with a declared replicate axis; the compiler verifies that no reaction crosses replicates, which lets the batched direct stochastic simulation algorithm give every replicate its own event clock. The direct SSA generates exact draws from the specified continuous-time Markov jump process; "exact" refers to that process, not to the ODE or to any disease. (a) 256 paths against the deterministic solution of the same specification. Finite-population extinction is visible: in this seeded sample 26.2% of paths have no infectious hosts at the final time, and the median sits below the deterministic second wave. (b) Mean cumulative events per path from the retained firing counts. Two identities hold exactly, by array equality, on every path: the total population is constant, and the state equals the initial state plus the stoichiometry matrix times the cumulative counts. Illustrative parameters. Figure downloads, data and source.
Two-panel heat-equation verification comparing a 16-interval finite-difference solution with the analytic solution and showing maximum error over five meshes. Details follow.
Convergence of a supplied spatial operator to an analytic solution. The heat equation on [0, 1] with zero boundary values and a sine initial condition has the closed-form solution sin(πx) exp(−Dπ²t). A centred finite-difference operator is supplied explicitly and compiled as a named-axis contraction; OP Engine integrates it in time with a step small enough that spatial error dominates. (a) The exact and computed solutions at t = 0.5 on 16 mesh intervals (15 interior unknowns). (b) Maximum error against the exact solution over five meshes, with fitted order 2.00. Checking against a known solution, rather than against another solver, is the standard verification practice for numerical codes (Roache 2002). Figure downloads, data and source.
Cubic-model bifurcation diagram showing two stable branches from vectorized solves, the unstable branch from the polynomial roots, and the interval with two stable states. Details follow.
Equilibria by vectorized steady-state solves. For the bistable model x′ = a + x − x³, the engine's pseudo-transient steady-state solver is mapped over 121 values of a with jax.vmap from two starting guesses; with early exit disabled, each solve is a fixed-length traced loop. These are independent solves at each parameter value, not continuation along a branch. Every state with a true convergence flag lies within 10−6 of a root of the cubic; states with a false flag occur only where the branch being sought does not exist past a fold, and they are omitted from the plot. The unstable branch is drawn from the cubic's roots as a reference. A one-state toy chosen for its closed-form check; it is not the published plankton model on the research page. Figure downloads, data and source.

Architecture diagrams and other figure downloads