# somnath1077/statistical_rethinking architecture

> Architecture diagram of the GitHub repository somnath1077/statistical_rethinking, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/somnath1077/statistical_rethinking
- Repository: https://github.com/somnath1077/statistical_rethinking

## Overview

##### Main Components
- Course Content Modules: Organize the code under the “code” directory into separate components by chapter (e.g., ch02, ch04, …, ch11). Each chapter folder contains one or more Python scripts or Jupyter Notebooks illustrating specific statistical topics.
- Jupyter Notebook Environment: Since many of the examples are provided as notebooks (*.ipynb), emphasize that these are the interactive components where users experiment with Bayesian models and statistical concepts.
- Data Resources: Include the “data” directory that contains CSV files. These datasets are utilized in different chapters for model fitting and demonstrations.
- Documentation and Notes: Highlight the “notes_ex” directory (with TeX and PDF files) which contains lecture notes and detailed explanations. This serves as the theoretical and explanatory backbone of the project.
- Supplementary Resources: Indicate the “papers” directory which contains academic papers that support deeper understanding of methodologies (e.g., WAIC, Bayesian evaluation).
- Environment and Configuration: Represent the configuration files like “environment.yml” and “requirements.txt” that show how the virtual environment (using Conda) is created, ensuring reproducibility with necessary dependencies like PyMC3.

##### Relationships and Interactions
- The notebooks serve both as demonstrative code and interactive analysis environments. They can be depicted as linking the theoretical notes with the practical examples.
- The environment files ensure that all code modules have proper dependencies. A component for “Dependencies” should link to every code example to signal that the correct Python packages (especially PyMC3) are required.
- The supplementary papers and external notes can be shown as reference resources that provide deeper context to the code and notebooks.

##### Architectural Patterns and Design Principles
- Modularity: The repository is segmented by chapter, indicating a modular design where each module (or component) is dedicated to a particular topic or technique in Bayesian statistics.
- Separation of Concerns: There’s a clear separation between theoretical material (notes, papers), practical code (scripts and notebooks), and data. This separation can be captured by grouping related components together.
- Reproducibility: The environment configuration files highlight reproducibility of results by enabling users to create a consistent virtual environment.

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% Infrastructure Layer: Environment and Configuration
    subgraph "Infrastructure Layer"
        ENV_YML["environment.yml"]:::config
        REQ["requirements.txt"]:::config
    end

    %% Application/Module Layer
    subgraph "Application/Module Layer"
        subgraph "Course Content Modules"
            CH02["Chapter 02"]:::chapter
            CH04["Chapter 04"]:::chapter
            CH05["Chapter 05"]:::chapter
            CH06["Chapter 06"]:::chapter
            CH07["Chapter 07"]:::chapter
            CH08["Chapter 08"]:::chapter
            CH09["Chapter 09"]:::chapter
            CH10["Chapter 10"]:::chapter
            CH11["Chapter 11"]:::chapter
        end

        subgraph "Jupyter Notebook Environment"
            NB_CH04["NB - ch04: howell_data"]:::notebook
            NB_CH09["NB - ch09: metropolis"]:::notebook
        end
    end

    %% Resource/Reference Layer
    subgraph "Resource/Reference Layer"
        subgraph "Data Resources"
            DATA["Data (CSV files)"]:::data
        end

        subgraph "Documentation and Notes"
            NOTES_CH02["CH02 Notes"]:::notes
            NOTES_CH07["CH07 Notes"]:::notes
            NOTES_CH10["CH10 Notes"]:::notes
            LECTURE_PDF["Lecture PDF"]:::notes
            LECTURE_TEX["Lecture TeX"]:::notes
        end

        subgraph "Supplementary Papers"
            PAPER_WAIC["Practical Bayesian Model Evaluation"]:::paper
            PAPER_PSIG["Vehtari Gelman Gabry PSIS"]:::paper
            PAPER_UWAIC["Understanding WAIC"]:::paper
        end
    end

    %% Relationships
    %% Environment configuration provides dependencies for course modules and notebooks
    ENV_YML -->|"dependency"| CH02
    ENV_YML -->|"dependency"| CH04
    ENV_YML -->|"dependency"| CH05
    ENV_YML -->|"dependency"| CH06
    ENV_YML -->|"dependency"| CH07
    ENV_YML -->|"dependency"| CH08
    ENV_YML -->|"dependency"| CH09
    ENV_YML -->|"dependency"| CH10
    ENV_YML -->|"dependency"| CH11
    REQ -->|"dependency"| CH02
    REQ -->|"dependency"| CH04
    REQ -->|"dependency"| CH05
    REQ -->|"dependency"| CH06
    REQ -->|"dependency"| CH07
    REQ -->|"dependency"| CH08
    REQ -->|"dependency"| CH09
    REQ -->|"dependency"| CH10
    REQ -->|"dependency"| CH11

    %% Data flows from Data Resources to Course Content Modules and Notebooks
    DATA -->|"loads"| CH02
    DATA -->|"loads"| CH04
    DATA -->|"loads"| CH05
    DATA -->|"loads"| CH06
    DATA -->|"loads"| CH07
    DATA -->|"loads"| CH08
    DATA -->|"loads"| CH09
    DATA -->|"loads"| CH10
    DATA -->|"loads"| CH11
    DATA -->|"loads"| NB_CH04
    DATA -->|"loads"| NB_CH09

    %% Notebooks link to their respective chapters
    NB_CH04 -->|"demonstrates"| CH04
    NB_CH09 -->|"demonstrates"| CH09

    %% Documentation provides theoretical backing to the notebooks
    NOTES_CH02 -->|"supports"| NB_CH04
    NOTES_CH07 -->|"supports"| NB_CH09
    NOTES_CH10 -->|"supports"| CH10
    LECTURE_PDF -->|"guides"| NB_CH04
    LECTURE_TEX -->|"guides"| NB_CH09

    %% Supplementary papers reference the documentation
    PAPER_WAIC -->|"references"| NOTES_CH10
    PAPER_PSIG -->|"references"| NOTES_CH07
    PAPER_UWAIC -->|"references"| NOTES_CH02

    %% Styles
    classDef chapter fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef notebook fill:#F9E79F,stroke:#B9770E,stroke-width:2px;
    classDef data fill:#A9DFBF,stroke:#1E8449,stroke-width:2px;
    classDef notes fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
    classDef paper fill:#F5CBA7,stroke:#B9770E,stroke-width:2px;
    classDef config fill:#FAD7A0,stroke:#BA4A00,stroke-width:2px;

    %% Click Events for Course Content Modules
    click CH02 "https://github.com/somnath1077/statistical_rethinking/tree/master/code/ch02"
    click CH04 "https://github.com/somnath1077/statistical_rethinking/tree/master/code/ch04"
    click CH05 "https://github.com/somnath1077/statistical_rethinking/tree/master/code/ch05"
    click CH06 "https://github.com/somnath1077/statistical_rethinking/tree/master/code/ch06"
    click CH07 "https://github.com/somnath1077/statistical_rethinking/tree/master/code/ch07"
    click CH08 "https://github.com/somnath1077/statistical_rethinking/tree/master/code/ch08"
    click CH09 "https://github.com/somnath1077/statistical_rethinking/tree/master/code/ch09"
    click CH10 "https://github.com/somnath1077/statistical_rethinking/tree/master/code/ch10"
    click CH11 "https://github.com/somnath1077/statistical_rethinking/tree/master/code/ch11"

    %% Click Events for Jupyter Notebook Environment
    click NB_CH04 "https://github.com/somnath1077/statistical_rethinking/blob/master/code/ch04/nb01_howell_data.ipynb"
    click NB_CH09 "https://github.com/somnath1077/statistical_rethinking/blob/master/code/ch09/nb01_metropolis.ipynb"

    %% Click Event for Data Resources
    click DATA "https://github.com/somnath1077/statistical_rethinking/tree/master/data"

    %% Click Events for Documentation and Notes
    click NOTES_CH02 "https://github.com/somnath1077/statistical_rethinking/blob/master/notes_ex/ch02.tex"
    click NOTES_CH07 "https://github.com/somnath1077/statistical_rethinking/blob/master/notes_ex/ch07.tex"
    click NOTES_CH10 "https://github.com/somnath1077/statistical_rethinking/blob/master/notes_ex/ch10.tex"
    click LECTURE_PDF "https://github.com/somnath1077/statistical_rethinking/blob/master/notes_ex/stat_rethink.pdf"
    click LECTURE_TEX "https://github.com/somnath1077/statistical_rethinking/blob/master/notes_ex/stat_rethink.tex"

    %% Click Events for Supplementary Papers
    click PAPER_WAIC "https://github.com/somnath1077/statistical_rethinking/blob/master/papers/Practical_Bayesian_Model_Evaluation_Using_WAIC.pdf"
    click PAPER_PSIG "https://github.com/somnath1077/statistical_rethinking/blob/master/papers/Vehtari_Gelman_Gabry_PSIS_2017.pdf"
    click PAPER_UWAIC "https://github.com/somnath1077/statistical_rethinking/blob/master/papers/understanding_waic.pdf"

    %% Click Events for Environment and Configuration
    click ENV_YML "https://github.com/somnath1077/statistical_rethinking/blob/master/environment.yml"
    click REQ "https://github.com/somnath1077/statistical_rethinking/blob/master/requirements.txt"
```
