# lowgroundmikean/monte-carlo-integration-on-heart-4.2 architecture

> Architecture diagram of the GitHub repository lowgroundmikean/monte-carlo-integration-on-heart-4.2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lowgroundmikean/monte-carlo-integration-on-heart-4.2
- Repository: https://github.com/lowgroundmikean/monte-carlo-integration-on-heart-4.2

## Overview

This repository is an MPI research program for estimating the area of a planar heart and comparing whole-box sampling with vertical, horizontal, and 2-D stratification. Its main workflow runs experiments that emit per-stream CSV measurements, then analyzes those measurements into error, variance-reduction, and scaling summaries; a separate report generator also consumes the raw CSV. The C implementation is largely monolithic, so its sampling, geometry, RNG, and reduction responsibilities are shown as layers of the same source file. Analysis and report-generation links follow the README; unsampled job-launch and packaging machinery is omitted.

Main entry points: [`heart_mc.c`](https://github.com/lowgroundmikean/monte-carlo-integration-on-heart-4.2/blob/main/heart_mc.c) (MPI experiment driver), [`results_2451063.csv`](https://github.com/lowgroundmikean/monte-carlo-integration-on-heart-4.2/blob/main/results_2451063.csv) (Per-stream measurements), [`analyze.py`](https://github.com/lowgroundmikean/monte-carlo-integration-on-heart-4.2/blob/main/analyze.py) (CSV analysis), [`build_reportp42.py`](https://github.com/lowgroundmikean/monte-carlo-integration-on-heart-4.2/blob/main/build_reportp42.py) (PDF report generator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_simulation["Monte Carlo simulation"]
  node_driver["MPI experiment driver<br/>[heart_mc.c]"]
  node_strata["Stratum assignment<br/>[heart_mc.c]"]
  node_sampler["Point sampling<br/>[heart_mc.c]"]
  node_geometry["Heart membership test<br/>[heart_mc.c]"]
  node_rng["Random stream generator<br/>[heart_mc.c]"]
  node_seeding["Stream initialization<br/>[heart_mc.c]"]
  node_reduction["MPI estimate reduction<br/>[heart_mc.c]"]
  node_csv_emit["CSV row output<br/>[heart_mc.c]"]
end

subgraph group_measurements["Measurement data"]
  node_raw_csv["Per-stream measurements"]
end

subgraph group_analysis["Results analysis"]
  node_analyzer["CSV analysis<br/>[analyze.py]"]
  node_summaries["Tables and plot data<br/>[analyze.py]"]
end

subgraph group_reporting["Research report"]
  node_report_builder["PDF report generator<br/>[build_reportp42.py]"]
  node_report_pdf["Project report"]
end

node_operator(("Experiment operator"))

node_operator -->|"launches"| node_driver
node_driver -->|"assigns regions"| node_strata
node_driver -->|"initializes streams"| node_seeding
node_seeding -->|"seeds with SplitMix64"| node_rng
node_driver -->|"draws points"| node_sampler
node_sampler -->|"gets random values"| node_rng
node_sampler -->|"tests membership"| node_geometry
node_driver -->|"reduces estimates"| node_reduction
node_reduction -->|"returns total"| node_csv_emit
node_csv_emit -->|"writes rows"| node_raw_csv
node_raw_csv -->|"loads measurements"| node_analyzer
node_analyzer -->|"generates summaries"| node_summaries
node_raw_csv -->|"reads measurements"| node_report_builder
node_report_builder -->|"generates PDF"| node_report_pdf

click node_driver "https://github.com/lowgroundmikean/monte-carlo-integration-on-heart-4.2/blob/main/heart_mc.c"
click node_strata "https://github.com/lowgroundmikean/monte-carlo-integration-on-heart-4.2/blob/main/heart_mc.c"
click node_sampler "https://github.com/lowgroundmikean/monte-carlo-integration-on-heart-4.2/blob/main/heart_mc.c"
click node_geometry "https://github.com/lowgroundmikean/monte-carlo-integration-on-heart-4.2/blob/main/heart_mc.c"
click node_rng "https://github.com/lowgroundmikean/monte-carlo-integration-on-heart-4.2/blob/main/heart_mc.c"
click node_seeding "https://github.com/lowgroundmikean/monte-carlo-integration-on-heart-4.2/blob/main/heart_mc.c"
click node_reduction "https://github.com/lowgroundmikean/monte-carlo-integration-on-heart-4.2/blob/main/heart_mc.c"
click node_csv_emit "https://github.com/lowgroundmikean/monte-carlo-integration-on-heart-4.2/blob/main/heart_mc.c"
click node_raw_csv "https://github.com/lowgroundmikean/monte-carlo-integration-on-heart-4.2/blob/main/results_2451063.csv"
click node_analyzer "https://github.com/lowgroundmikean/monte-carlo-integration-on-heart-4.2/blob/main/analyze.py"
click node_summaries "https://github.com/lowgroundmikean/monte-carlo-integration-on-heart-4.2/blob/main/analyze.py"
click node_report_builder "https://github.com/lowgroundmikean/monte-carlo-integration-on-heart-4.2/blob/main/build_reportp42.py"
click node_report_pdf "https://github.com/lowgroundmikean/monte-carlo-integration-on-heart-4.2/blob/main/Michael%20Guerrero-AMS%20530-4.2%20Paper.pdf"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_driver,node_strata,node_sampler,node_geometry,node_rng,node_seeding,node_reduction,node_csv_emit toneBlue
class node_raw_csv toneAmber
class node_analyzer,node_summaries toneMint
class node_report_builder,node_report_pdf toneRose
class node_operator toneIndigo
```

## Components

### Monte Carlo simulation

- [MPI experiment driver](https://github.com/lowgroundmikean/monte-carlo-integration-on-heart-4.2/blob/main/heart_mc.c): `heart_mc.c`
- [Stratum assignment](https://github.com/lowgroundmikean/monte-carlo-integration-on-heart-4.2/blob/main/heart_mc.c): `heart_mc.c`
- [Point sampling](https://github.com/lowgroundmikean/monte-carlo-integration-on-heart-4.2/blob/main/heart_mc.c): `heart_mc.c`
- [Heart membership test](https://github.com/lowgroundmikean/monte-carlo-integration-on-heart-4.2/blob/main/heart_mc.c): `heart_mc.c`
- [Random stream generator](https://github.com/lowgroundmikean/monte-carlo-integration-on-heart-4.2/blob/main/heart_mc.c): `heart_mc.c`
- [Stream initialization](https://github.com/lowgroundmikean/monte-carlo-integration-on-heart-4.2/blob/main/heart_mc.c): `heart_mc.c`
- [MPI estimate reduction](https://github.com/lowgroundmikean/monte-carlo-integration-on-heart-4.2/blob/main/heart_mc.c): `heart_mc.c`
- [CSV row output](https://github.com/lowgroundmikean/monte-carlo-integration-on-heart-4.2/blob/main/heart_mc.c): `heart_mc.c`

### Measurement data

- [Per-stream measurements](https://github.com/lowgroundmikean/monte-carlo-integration-on-heart-4.2/blob/main/results_2451063.csv): `results_2451063.csv`

### Results analysis

- [CSV analysis](https://github.com/lowgroundmikean/monte-carlo-integration-on-heart-4.2/blob/main/analyze.py): `analyze.py`
- [Tables and plot data](https://github.com/lowgroundmikean/monte-carlo-integration-on-heart-4.2/blob/main/analyze.py): `analyze.py`

### Research report

- [PDF report generator](https://github.com/lowgroundmikean/monte-carlo-integration-on-heart-4.2/blob/main/build_reportp42.py): `build_reportp42.py`
- [Project report](https://github.com/lowgroundmikean/monte-carlo-integration-on-heart-4.2/blob/main/Michael%20Guerrero-AMS%20530-4.2%20Paper.pdf): `Michael Guerrero-AMS 530-4.2 Paper.pdf`

### Other components

- **Experiment operator**

## Connections

- Experiment operator → MPI experiment driver: launches (evidence: `README.md`)
- MPI experiment driver → Stratum assignment: assigns regions (evidence: `heart_mc.c`)
- MPI experiment driver → Stream initialization: initializes streams (evidence: `heart_mc.c`)
- Stream initialization → Random stream generator: seeds with SplitMix64 (evidence: `heart_mc.c`)
- MPI experiment driver → Point sampling: draws points (evidence: `heart_mc.c`)
- Point sampling → Random stream generator: gets random values (evidence: `heart_mc.c`)
- Point sampling → Heart membership test: tests membership (evidence: `heart_mc.c`)
- MPI experiment driver → MPI estimate reduction: reduces estimates (evidence: `heart_mc.c`)
- MPI estimate reduction → CSV row output: returns total (evidence: `heart_mc.c`)
- CSV row output → Per-stream measurements: writes rows (evidence: `heart_mc.c`)
- Per-stream measurements → CSV analysis: loads measurements (evidence: `analyze.py`)
- CSV analysis → Tables and plot data: generates summaries (evidence: `analyze.py`)
- Per-stream measurements → PDF report generator: reads measurements (evidence: `README.md`)
- PDF report generator → Project report: generates PDF (evidence: `README.md`)
