1import marimo2
3__generated_with = "0.13.0"4app = marimo.App()5
6
7@app.cell8def intro():9 import marimo as mo10 mo.md("""11 # DAG Demo12
13 this notebook has a non-trivial dependency graph to test DAG visualization.14 cells form a diamond pattern: config feeds into both branch_a and branch_b,15 which both feed into merge.16 """)17 return (mo,)18
19
20@app.cell21def config():22 n_samples = 100023 seed = 4224 return (n_samples, seed)25
26
27@app.cell28def branch_a(n_samples, seed):29 import random30 random.seed(seed)31 values_a = [random.gauss(0, 1) for _ in range(n_samples)]32 mean_a = sum(values_a) / len(values_a)33 print(f"branch A: {n_samples} samples, mean={mean_a:.4f}")34 return (values_a, mean_a)35
36
37@app.cell38def branch_b(n_samples, seed):39 import random40 random.seed(seed + 1)41 values_b = [random.uniform(-2, 2) for _ in range(n_samples)]42 mean_b = sum(values_b) / len(values_b)43 print(f"branch B: {n_samples} samples, mean={mean_b:.4f}")44 return (values_b, mean_b)45
46
47@app.cell48def merge(values_a, values_b, mean_a, mean_b):49 combined = values_a + values_b50 total_mean = sum(combined) / len(combined)51 print(f"merged: {len(combined)} total samples")52 print(f" branch A mean: {mean_a:.4f}")53 print(f" branch B mean: {mean_b:.4f}")54 print(f" combined mean: {total_mean:.4f}")55 return (combined,)56
57
58@app.cell59def final_stats(combined):60 sorted_vals = sorted(combined)61 n = len(sorted_vals)62 median = sorted_vals[n // 2]63 p95 = sorted_vals[int(n * 0.95)]64 p05 = sorted_vals[int(n * 0.05)]65 print(f"final stats:")66 print(f" median: {median:.4f}")67 print(f" p5-p95 range: [{p05:.4f}, {p95:.4f}]")68 return ()69
70
71if __name__ == "__main__":72 app.run() v1
commit 6238ad8
message create dag-demo.py via macOS
author anton
date Apr 20, 2026
size 1.7 KB