All examples
Scientific computing

Independent stochastic growth scenarios

Compare two explicit noise scale scenarios with 10000 independent multiplicative growth paths each, matched iteration seeds and full numeric output distributions.

repeat_scenarios.aner
// Two separate synthetic scenarios, 10000 independent repetitions per scenario; paths are matched across scenarios.
// This is a larger CPU workload than repeat_local.aner. No files are written by default.
import aner.parallel

// Synthetic multiplicative stochastic growth model; adapt its assumptions to your research question.
// Parameters: initial level, per-step drift, noise scale, number of steps.
// The abstract level has no domain calibration or empirical predictive claim.
fn simulate_growth_path(parameters: List, iteration: Int64, seed: Int64) -> List {
    let initial_level = cast<Float64>(parameters.get(0))
    let drift = cast<Float64>(parameters.get(1))
    let noise_scale = cast<Float64>(parameters.get(2))
    let steps = cast<Int64>(parameters.get(3))
    var level = initial_level
    var peak = initial_level
    var largest_relative_decline = 0.0
    var step = 0
    while step < steps {
        let shock = parallel.normal(seed: seed, draw: step)
        level = level * (1.0 + drift + noise_scale * shock)
        if level > peak { peak = level }
        let relative_decline = (peak - level) / peak
        if relative_decline > largest_relative_decline { largest_relative_decline = relative_decline }
        step = step + 1
    }
    return List(level / initial_level - 1.0, largest_relative_decline)
}

let execution = parallel.local()
let lower_noise = parallel.repeat(iterations: 10000, task: simulate_growth_path,
    parameters: List(100000.0, 0.0002, 0.01, 64), execution: execution, seed: 42)
let higher_noise = parallel.repeat(iterations: 10000, task: simulate_growth_path,
    parameters: List(100000.0, 0.0002, 0.025, 64), execution: execution, seed: 42)
print(lower_noise.rows()) // 10000
print(higher_noise.rows())     // 10000
print(lower_noise.mean(column: 0))
print(lower_noise.std(column: 0, sample: true))
print(higher_noise.mean(column: 0))
print(higher_noise.std(column: 0, sample: true))
print(lower_noise.seed(iteration: 0) == higher_noise.seed(iteration: 0)) // true: matched stochastic paths
print(lower_noise.summary())
print(higher_noise.summary())
// Save separately to new destinations if needed; repeat runs refuse existing files.
// lower_noise.save_csv("lower_noise-results.csv")
// higher_noise.save_csv("higher_noise-results.csv")

Make it your experiment.

With Aner installed, save this program as examples/parallel/repeat_scenarios.aner inside a folder for your experiment. Open a terminal in that folder, then check and run the program.

Terminal
aner check examples/parallel/repeat_scenarios.aner
aner run examples/parallel/repeat_scenarios.aner

The aner command must be on your PATH. Follow the installation guide if your terminal cannot find it.

Use the updated native Aner executable with checked parallel.repeat tasks and SimulationResults. VS Code extension 0.1.39 supplies compatible argument and result help. These sources need no external data, service, network or credential. Checking performs no repetitions; running executes the declared local CPU work. Output CSV writes are explicit and commented in the growth examples, so a normal run creates no file. This larger example performs two separate 10000 path scenarios from identical initial inputs within each scenario. Matched master seeds deliberately reuse stochastic paths across parameter comparisons.

Bundled datasets retain their own source attribution and license notices. Example outcomes are not comparative benchmarks or evidence of clinical validity.

Dataset sources & attribution
Install Aner