# japanese-maple/computational_statistics architecture

> Architecture diagram of the GitHub repository japanese-maple/computational_statistics, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/japanese-maple/computational_statistics
- Repository: https://github.com/japanese-maple/computational_statistics

## Overview

#### Purpose and Entry Points
This is a notebook-first Python learning repository implementing and visualizing core computational statistics methods. Each top-level Jupyter notebook is an independent executable entry point rather than part of a packaged application:
- `0_Linear_Regression.ipynb`
- `1_Importance_Sampling.ipynb`
- `2_Metropolis-Hastings.ipynb`
- `3_Gibbs_Sampler.ipynb`

#### Execution Model
Users run notebooks interactively in a Jupyter-compatible Python environment. The notebooks likely combine method setup, numerical simulation, estimation, and visualization in one workflow. There is no indicated shared library, CLI, service runtime, deployment layer, or application backend.

#### Regression Workflow
`0_Linear_Regression.ipynb` represents the supervised-estimation portion of the repository. Its architectural role is to demonstrate fitting or visualizing a linear regression model from data, distinct from the later stochastic sampling methods. Generated artifacts are organized under `Outputs/Linear_regression`.

#### Importance Sampling Workflow
`1_Importance_Sampling.ipynb` implements an importance-sampling pipeline: samples are drawn from a proposal distribution, weighted relative to a target distribution, and aggregated into an estimate or visualization. Output material is separated at `Outputs/Importance_sampling`, making that directory the boundary between notebook computation and persisted results.

#### Markov Chain Monte Carlo Workflows
Two notebooks implement MCMC approaches:
- `2_Metropolis-Hastings.ipynb` defines the proposal/acceptance/rejection chain workflow associated with Metropolis-Hastings; outputs belong in `Outputs/Metropolis-Hastings`.
- `3_Gibbs_Sampler.ipynb` defines a Gibbs-sampling workflow, where state updates are expected to be conditional-coordinate transitions.

These are separate pedagogical implementations, not alternate modules behind a common sampler interface.

#### Data and Control Flow
The main flow is notebook-local: initialize distributions or data, execute numerical/statistical iterations, then render and/or save results. The `Outputs` hierarchy is the only explicit shared persistence structure:
- `Outputs`
- `Outputs/Importance_sampling`
- `Outputs/Linear_regression`
- `Outputs/Metropolis-Hastings`

No input datasets, databases, message queues, HTTP APIs, or external services are represented in the repository tree.

#### Infrastructure and Boundaries
The material runtime is Python via Jupyter notebooks. Python numerical and plotting dependencies are implied by the stated implementations and visualizations, but no dependency manifest is present. `README.md` provides the project-level description, while `LICENSE` defines distribution terms. The absence of package source directories and environment configuration means reproducibility and dependency installation are notebook/user-environment responsibilities.

Main entry points: [`Outputs`](https://github.com/japanese-maple/computational_statistics/tree/main/Outputs) (Outputs), [`0_Linear_Regression.ipynb`](https://github.com/japanese-maple/computational_statistics/blob/main/0_Linear_Regression.ipynb) (Linear Regression), [`1_Importance_Sampling.ipynb`](https://github.com/japanese-maple/computational_statistics/blob/main/1_Importance_Sampling.ipynb) (Importance Sampling), [`2_Metropolis-Hastings.ipynb`](https://github.com/japanese-maple/computational_statistics/blob/main/2_Metropolis-Hastings.ipynb) (Metropolis-Hastings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Interactive Runtime"]
  node_jupyter{{"Jupyter Python<br/>runtime"}}
end

subgraph group_workflows["Notebook Workflows"]
  node_linear_notebook["Linear Regression<br/>notebook"]
  node_linear_fit["Regression fit<br/>estimation stage"]
  node_importance_notebook["Importance Sampling<br/>notebook"]
  node_importance_weighting["Proposal weighting<br/>sampling stage"]
  node_mh_notebook["Metropolis-Hastings<br/>notebook"]
  node_mh_chain["Accept/reject chain<br/>MCMC stage"]
  node_gibbs_notebook["Gibbs Sampler<br/>notebook"]
  node_gibbs_updates["Conditional updates<br/>MCMC stage"]
end

subgraph group_outputs["Persisted Results"]
  node_outputs[("Outputs<br/>results root")]
  node_linear_outputs[("Regression results<br/>output directory")]
  node_importance_outputs[("Importance results<br/>output directory")]
  node_mh_outputs[("Metropolis-Hastings results<br/>output directory")]
end

node_readme["Project guide<br/>documentation<br/>[README.md]"]
node_license["License"]

node_readme -.->|"describes usage"| node_jupyter
node_license -.->|"defines terms"| node_readme
node_jupyter -->|"executes"| node_linear_notebook
node_jupyter -->|"executes"| node_importance_notebook
node_jupyter -->|"executes"| node_mh_notebook
node_jupyter -->|"executes"| node_gibbs_notebook
node_linear_notebook -->|"fits and visualizes"| node_linear_fit
node_linear_fit -->|"persists results"| node_linear_outputs
node_importance_notebook -->|"runs"| node_importance_weighting
node_importance_weighting -->|"persists results"| node_importance_outputs
node_mh_notebook -->|"runs"| node_mh_chain
node_mh_chain -->|"persists results"| node_mh_outputs
node_gibbs_notebook -->|"runs"| node_gibbs_updates
node_outputs -->|"contains"| node_linear_outputs
node_outputs -->|"contains"| node_importance_outputs
node_outputs -->|"contains"| node_mh_outputs

click node_readme "https://github.com/japanese-maple/computational_statistics/blob/main/README.md"
click node_license "https://github.com/japanese-maple/computational_statistics/blob/main/LICENSE"
click node_linear_notebook "https://github.com/japanese-maple/computational_statistics/blob/main/0_Linear_Regression.ipynb"
click node_importance_notebook "https://github.com/japanese-maple/computational_statistics/blob/main/1_Importance_Sampling.ipynb"
click node_mh_notebook "https://github.com/japanese-maple/computational_statistics/blob/main/2_Metropolis-Hastings.ipynb"
click node_gibbs_notebook "https://github.com/japanese-maple/computational_statistics/blob/main/3_Gibbs_Sampler.ipynb"
click node_outputs "https://github.com/japanese-maple/computational_statistics/tree/main/Outputs"
click node_linear_outputs "https://github.com/japanese-maple/computational_statistics/tree/main/Outputs/Linear_regression"
click node_importance_outputs "https://github.com/japanese-maple/computational_statistics/tree/main/Outputs/Importance_sampling"
click node_mh_outputs "https://github.com/japanese-maple/computational_statistics/tree/main/Outputs/Metropolis-Hastings"

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_jupyter toneBlue
class node_linear_notebook,node_linear_fit,node_importance_notebook,node_importance_weighting,node_mh_notebook,node_mh_chain,node_gibbs_notebook,node_gibbs_updates toneAmber
class node_outputs,node_linear_outputs,node_importance_outputs,node_mh_outputs toneMint
class node_readme,node_license toneNeutral
```

## Components

### Interactive Runtime

- **Jupyter Python**: runtime · Users execute each notebook interactively.

### Notebook Workflows

- [Linear Regression](https://github.com/japanese-maple/computational_statistics/blob/main/0_Linear_Regression.ipynb): notebook · Supervised estimation and visualization workflow. · `0_Linear_Regression.ipynb`
- **Regression fit**: estimation stage
- [Importance Sampling](https://github.com/japanese-maple/computational_statistics/blob/main/1_Importance_Sampling.ipynb): notebook · `1_Importance_Sampling.ipynb`
- **Proposal weighting**: sampling stage · Draw proposal samples, weight against the target, and aggregate estimates.
- [Metropolis-Hastings](https://github.com/japanese-maple/computational_statistics/blob/main/2_Metropolis-Hastings.ipynb): notebook · `2_Metropolis-Hastings.ipynb`
- **Accept/reject chain**: MCMC stage · Proposal, acceptance, and rejection transitions.
- [Gibbs Sampler](https://github.com/japanese-maple/computational_statistics/blob/main/3_Gibbs_Sampler.ipynb): notebook · `3_Gibbs_Sampler.ipynb`
- **Conditional updates**: MCMC stage · Coordinate-wise conditional state transitions.

### Persisted Results

- [Outputs](https://github.com/japanese-maple/computational_statistics/tree/main/Outputs): results root · Shared persisted-results hierarchy. · `Outputs`
- [Regression results](https://github.com/japanese-maple/computational_statistics/tree/main/Outputs/Linear_regression): output directory · `Outputs/Linear_regression`
- [Importance results](https://github.com/japanese-maple/computational_statistics/tree/main/Outputs/Importance_sampling): output directory · `Outputs/Importance_sampling`
- [Metropolis-Hastings results](https://github.com/japanese-maple/computational_statistics/tree/main/Outputs/Metropolis-Hastings): output directory · `Outputs/Metropolis-Hastings`

### Other components

- [Project guide](https://github.com/japanese-maple/computational_statistics/blob/main/README.md): documentation · `README.md`
- [License](https://github.com/japanese-maple/computational_statistics/blob/main/LICENSE): license · `LICENSE`

## Connections

- Project guide → Jupyter Python: describes usage
- License → Project guide: defines terms
- Jupyter Python → Linear Regression: executes
- Jupyter Python → Importance Sampling: executes
- Jupyter Python → Metropolis-Hastings: executes
- Jupyter Python → Gibbs Sampler: executes
- Linear Regression → Regression fit: fits and visualizes
- Regression fit → Regression results: persists results
- Importance Sampling → Proposal weighting: runs
- Proposal weighting → Importance results: persists results
- Metropolis-Hastings → Accept/reject chain: runs
- Accept/reject chain → Metropolis-Hastings results: persists results
- Gibbs Sampler → Conditional updates: runs
- Outputs → Regression results: contains
- Outputs → Importance results: contains
- Outputs → Metropolis-Hastings results: contains
