{"id":35211808,"url":"https://github.com/joaoflavioufmg/desk","last_synced_at":"2026-04-27T04:00:53.599Z","repository":{"id":331702944,"uuid":"1074972904","full_name":"joaoflavioufmg/desk","owner":"joaoflavioufmg","description":"Discrete Event Simulation Kit","archived":false,"fork":false,"pushed_at":"2026-03-10T22:34:56.000Z","size":81370,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-18T08:51:00.653Z","etag":null,"topics":["discrete-event-simulation","experiment-design","factorial-analysis","open-source","simpy"],"latest_commit_sha":null,"homepage":"https://desk-sim.readthedocs.io/en/latest/","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joaoflavioufmg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-12T20:28:45.000Z","updated_at":"2026-03-10T22:34:59.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/joaoflavioufmg/desk","commit_stats":null,"previous_names":["joaoflavioufmg/desk"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/joaoflavioufmg/desk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joaoflavioufmg%2Fdesk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joaoflavioufmg%2Fdesk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joaoflavioufmg%2Fdesk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joaoflavioufmg%2Fdesk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joaoflavioufmg","download_url":"https://codeload.github.com/joaoflavioufmg/desk/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joaoflavioufmg%2Fdesk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32321940,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T23:26:28.701Z","status":"online","status_checked_at":"2026-04-27T02:00:06.769Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["discrete-event-simulation","experiment-design","factorial-analysis","open-source","simpy"],"created_at":"2025-12-29T19:00:36.498Z","updated_at":"2026-04-27T04:00:53.593Z","avatar_url":"https://github.com/joaoflavioufmg.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DESK — Discrete Event Simulation Kit\n\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.18088013.svg)](https://doi.org/10.5281/zenodo.18088013)\n[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](LICENSE)\n![CI](https://github.com/joaoflavioufmg/desk/actions/workflows/tests.yml/badge.svg)![Docs](https://github.com/joaoflavioufmg/desk/actions/workflows/deploy-docs.yml/badge.svg?branch=main)\n[![Documentation Status](https://readthedocs.org/projects/desk-sim/badge/?version=latest)](https://desk-sim.readthedocs.io/en/latest/?badge=latest)\n\n\nA comprehensive Python framework for **Discrete Event Simulation** [1,2] with advanced analysis, visualization, and experimental design capabilities.\n\n---\n\n## 📋 Overview\n\n**DESK (Discrete Event Simulation Kit)** is a professional-grade simulation framework built on top of **SimPy** [3], designed for modeling complex systems such as hospitals, call centers, manufacturing, and service operations.\n\nDESK addresses the gap of structured experimental design [4] and replication automation in discrete-event simulation [1,2] workflows.\n\nThe open-source framework [5] emphasizes:\n- modularity,\n- reusability,\n- transparency (visualization and event logs),\n- and statistical analysis.\n\nDESK is suitable for **applied decision support, teaching, and research**.\n\n---\n\n## ✨ Key Features\n\n### Core Simulation Engine\n- **Modular Block Architecture**: Reusable building blocks (`CREATE`, `PROCESS`, `DECIDE`, `DISPOSE`)\n- **Advanced Resource Management**: Regular, priority-based, and preemptive resources\n- **Entity Attributes \u0026 State Variables**: Dynamic assignment and modification\n- **Priority Scheduling**: Activity-level and entity-level priority control\n- **Event Tracing**: Event logging with filtering and replay\n- **Visualization**: Graphical interface synchronized with event log printing\n\n![Visualization](figs/hospital-step.gif)\n\n---\n\n### Input Analysis (`desk-distfit`)\n- **DistFit Tool**: Automated distribution fitting with statistical tests (`desk-distfit`) \n- Supports 9+ distributions:\n  - uniform, triangular, exponential, normal, lognormal, beta, gamma, Weibull\n- Kolmogorov–Smirnov goodness-of-fit tests\n- Multiple output formats: table, JSON, CSV\n\n![DistFit](figs/dist.png)\n\nSee [DESK Distribution Fitting Tool](#desk-distribution-fitting-tool-desk-distfit) for further details.\n\n---\n\n### Experimental Design \u0026 Analysis\n- **Stability Analysis**: Preliminary capacity analysis on utilization (ρ \u003c 1)\n- **Little’s Law verification**: Automatic analysis on stability (**L = λW**). *The average number of items in the system (L) is the average arrival rate (λ) multiplied by the average time an item spends in the system (W)* \n- **Warm-Up Analysis**: Automated transient detection\n- **Replication Framework**: (Simulation) Automated multi-run experiments with confidence intervals\n- **Factorial Experiments**: Full factorial design with interaction analysis\n\n![Use](figs/use.png)\n---\n\n### Performance Metrics\n- **Entity Metrics**: System time, queue time, service time\n- **Resource Metrics**: Utilization, queue length, busy/idle time\n- **WIP Tracking**: Time-weighted work-in-process analysis\n- **Financial Analysis**: Cost and revenue per activity\n\n\n![WIP](figs/wip.png)\n---\n\n### Visualization \u0026 Reporting\n- **Real-Time Visualization**: Process animation during simulation\n\n![Visualization](figs/hospital.gif)\n\n- **Statistical Plots**:\n  - Resource utilization over time\n  - WIP evolution\n  - System time distributions\n  - Activity-level metrics\n- **BupaR Integration**: Process mining and animation files for ProcessAnimate in R ([processanimateR](https://bupaverse.github.io/processanimateR/)).\n\n- **Automated Reports**: Simulation results with diagnostics and recommendations\n---\n\n## 🚀 Quick Start\n\n### Installation\n\n```bash\n# Clone the repository\ngit clone https://github.com/joaoflavioufmg/desk.git\ncd desk\n\n# Install dependencies\npip install .\n# or\npip install -e .\n\n# Then test:\ndesk-sim -h\ndesk-sim -m examples/hospital.py --mode visualization\n\ndesk-distfit -h\ndesk-distfit -d input_data/data10.txt\n```\n\n\n# DESK — Discrete Event Simulation Kit\n\n## 🚀 Basic Example \n\nPatients arrive at a hospital emergency department, where they are assessed through a triage system and then directed to the appropriate hospital units. The conceptual model is presented* below. \n\n---\n**DESK adopts BPMN (.bpmn) as an open, tool-independent notation for representing activity-cycle and process-interaction models. Although BPMN is not a simulation-native language, its standardized semantics and widespread support make it a suitable representation for discrete-event simulation models.*\n\nModels in `.bpmn` format can be created and shared using the\n[BPMN Web Modeler (bpmn.io)](https://demo.bpmn.io/).\n\n---\n![Basic example BPMN](figs/basic.svg)\n---\n\n(A single replication)\n\nCreate a `basic.py` file and Copy/Paste the Part1 code below.\n\nFollowing, run: `desk-sim -m basic.py --mode single`\n\n```python\n# ==============================================================\n# Part 1: Basic simulation model: Nurses on emergency triage (hospital)\n# ==============================================================\n\ndef build_model(until=None, event_logger=None, verbose=True): \n    \n    import random\n    from desk.core.simulation_model import SimulationModel\n    from desk.core.entity import EventLogger\n    from desk.blocks.create_block import CreateBlock\n    from desk.blocks.process_block import ProcessBlock\n    from desk.blocks.dispose_block import DisposeBlock\n    \n    # Create model\n    model = SimulationModel(verbose=verbose)\n\n    # Add resources\n    nurses = model.add_resource(\"Nurses\", capacity=3)\n\n    # Define blocks\n    arrivals = CreateBlock(\n        \"Arrivals\", model.env,\n        inter_arrival_time=lambda: random.expovariate(1/10),\n        entity_prefix=\"Patient\",\n        event_logger=event_logger\n    )\n\n    triage = ProcessBlock(\n        \"Triage\", model.env,\n        resource=nurses,\n        delay_time=lambda: random.uniform(5, 10),\n        resource_units=1,\n        event_logger=event_logger\n    )\n\n    discharge = DisposeBlock(\"Discharge\", model.env, event_logger=event_logger)\n\n    # Register blocks\n    for block in [arrivals, triage, discharge]:\n        model.add_block(block)\n\n    # Connect flow\n    arrivals.connect_to(triage)\n    triage.connect_to(discharge)\n       \n    return model\n    \n    \n# Run a simulation replication\ndef main():\n    from desk.core.entity import EventLogger\n    \n    HOURS = 60  # Time conversion factor (base time: minutes)\n    DAYS = 1440\n    YEARS = 525600\n    \n    # Create event logger\n    event_logger = EventLogger()\n    \n    model = build_model(event_logger=event_logger, verbose=False)\n    \n    model.run_simulation(\n        until=8*HOURS,          # 8 hours\n        warm_up_period=1*HOURS,  # 1 hour\n        seed=123\n    )\n\n    # Report results\n    from desk.analytics.reporting import SimulationReporter\n    reporter = SimulationReporter(model)\n    reporter.print_results()\n    reporter._print_activity_metrics()\n    reporter._print_resource_metrics()\n    reporter._print_entity_counts()\n    reporter._print_block_statistics()\n    \n    return model, event_logger\n\n# ===========================================\n# Simulation Kit\n# ===========================================\n\n# Run a simulation replication\ndef run_single_replication():\n    return main()\n\n# Run a full simulation    \ndef run_replications_cli():\n    run_replications()\n\n# Run a factorial analysis\ndef run_factorial_cli():\n    return factorial_analysis()\n\n# Run the simulation with interface \ndef run_visualization_cli(simulation_time=500):\n    return run_visualization(build_model, simulation_time=simulation_time)\n```\n\n---\n## 📊 Simulation Analysis (Replications)\n\n\nNow, Copy/Paste the Part2 code below and add to the `basic.py` file.\n\nFollowing, run: `desk-sim -m basic.py --mode replications`\n\n```python\n# ... (after) \"return model, event_logger\"...\n# ==============================================================\n# Part 2: Additional code: Full simulation (replications framework)\n# ==============================================================\n\n# Define simulation function wrapper\ndef simulation_wrapper(seed=None, until=None, warm_up_period=None):\n    \"\"\"Wrapper function for replication framework.\"\"\"\n    \n    from desk.core.entity import EventLogger\n    event_logger = EventLogger()\n\n    # Create a fresh model\n    model = build_model(until=until, event_logger=event_logger, verbose=False)\n    \n    model.run_simulation(\n        validate_resources=False,\n        until=until,\n        seed=seed,\n        warm_up_period=warm_up_period\n    )\n    \n    return model\n\ndef run_replications():\n    from desk.stats.replication import ReplicationFramework\n    \n    replication_framework = ReplicationFramework(\n        simulation_function=simulation_wrapper,\n        n_replications=30\n    )\n\n    HOURS = 60  # Time conversion factor (base time: minutes)\n    DAYS = 1440\n    YEARS = 525600\n    \n    replication_framework.run_replications(\n        base_seed=12345,\n        until=8*HOURS,\n        warm_up_period=1*HOURS\n    )\n\n    # Access results\n    df = replication_framework.get_results_dataframe()\n    print(df.describe())\n   \n# ... keep the original (Simulation Kit) code\n# ===========================================\n# Simulation Kit\n# ===========================================\n\n```\n## 🧪 Experimental Design (Factorial)\n\nNow, Copy/Paste the Part3 code below and add to the `basic.py` file.\n\nFollowing, run: `desk-sim -m basic.py --mode factorial`\n\n\n```python\n# ... after \"print(df.describe())\"...\n# ==============================================================\n# Part 3: Additional code: Factorial experiment\n# ==============================================================\ndef factorial_analysis():\n    \"\"\"Factorial analysis with simulation.\"\"\"\n    \n    from desk.stats.factorial import FactorialExperiment\n\n    HOURS = 60  # Time conversion factor (base time: minutes)\n    DAYS = 1440\n    YEARS = 525600\n    \n\n    def simulation_wrapper(arrival_rate=1, num_nurses=1,\n                                seed=None, until=None, warm_up_period=0, **kwargs):\n        \"\"\"Wrapper that adapts parameters for factorial analysis.\"\"\"\n\n        from desk.core.entity import EventLogger\n        event_logger = EventLogger()\n\n        # Create a fresh model\n        model = build_model(until=until, event_logger=event_logger, verbose=False)\n        \n        model.run_simulation(\n            validate_resources=False,\n            until=until,\n            seed=seed,\n            warm_up_period=warm_up_period\n        )\n        \n        return model\n    \n    # Create factorial analysis\n    factorial = FactorialExperiment(\n        simulation_function=simulation_wrapper,\n        base_seed=12345\n    )\n    \n    # Add factors\n    factorial.add_factor(\n        factor_name='arrival_rate',\n        parameter_path='CreateBlock.inter_arrival_time',\n        levels=[1, 2, 3],  # Minutes between arrivals\n        description='Inter arrival rates (min)'\n    )\n    \n    factorial.add_factor(\n        factor_name='num_nurses',\n        parameter_path='Resource.nurses.capacity',\n        levels=[1, 2, 3],\n        description='Number of nurses'\n    )    \n    \n    # Run experiment\n    factorial.run_factorial_experiment(\n        n_replications=5,\n        simulation_time=4*HOURS,  # 4 hours\n        warm_up_period=1/2*HOURS,    # 1/2 hour\n        verbose=True\n    )\n    \n    # Analyze results\n    factorial.print_summary()\n    factorial.plot_correlation_matrix()\n    factorial.plot_main_effects('system_time_avg')\n    factorial.plot_interaction_effects('system_time_avg', 'arrival_rate', 'num_nurses')\n     \n    return factorial\n\n# ... keep the original (Simulation Kit) code\n# ===========================================\n# Simulation Kit\n# ===========================================\n```\n\n## 🔁 Run Interface (Visualization)\n\nFinally, Copy/Paste the Part4 code below and add to the `basic.py` file.\n\nFollowing, run: `desk-sim -m basic.py --mode visualization`\n\nActually, this can be the first part in a simulation study.\n\n\n```python\n# ... after \"return factorial\"...\n# ==============================================================\n# Part 4: Additional code: Interface - visualization\n# ==============================================================\nfrom desk.visualization.interface import run_visualization\n\n# ... keep the original (Simulation Kit) code\n# ===========================================\n# Simulation Kit\n# ===========================================\n```\n\n---\n\n## 📂 Project Structure\n\n```text\nDESK/\n├── src/                       # Source code of DESK\n|   ├── config/                # Simulation setting\n|   ├── core/                  # Core simulation engine\n|   ├── blocks/                # Simulation building blocks\n|   ├── analytics/             # Metrics, plots, reports\n|   ├── stats/                 # Replication \u0026 factorial design\n|   ├── validation/            # Stability and warm-up analysis\n|   ├── visualization/         # Real-time visualization\n|   ├── distfit/distfit.py     # DistFit CLI tool\n├── input_data/\n├── examples/\n├── 1) hospital.py             # Hospital example\n├── 2) 2.py                    # Restaurant example\n├── 3) 3.py, 3a.py, 3b.py      # Call center (and variations 3a, 3b)\n└── README.md\n```\n\n---\n\n## 🎓 Example Models\n\n1) **Hospital Emergency Department**\n  Triage, multiple resources, priority routing, financial tracking (`hospital.py`)\n\n2) **Restaurant Service**\n  Multi-resource activities, dynamic attributes, financials (`2.py`)\n\n3) **Call Center with Lost Calls**\n  Trunk capacity, blocking, retrials, custom KPIs (`3.py`, `3a.py`, `3b.py`)\n\n\n\n---\n## 🎓 Running examples\n\nFor each example, you can run: (1) replication, (2) full simulation, (3) factorial analysis and (4) visualization.\n\nDESK examples are executed **directly from the command line**, using explicit execution modes.\n\n\n---\n\n### 🔍 List available modes\n\nTo list the execution modes for a given model, e.g., `hospital.py`, type:\n\n```bash\ndesk-sim -m examples/hospital.py --list-modes\n```\n\n\n```text\nDESK execution modes:\n\n  --mode single         → run a single replication\n  --mode replications   → run the full simulation\n  --mode factorial      → run a factorial analysis\n  --mode visualization  → run simulation interface\n```\n\n---\n\n### 🔁 Interactive visualization\n\nRuns the model using the **DESK visualization interface**, enabling interactive inspection of the evolving system.\n\n```bash\ndesk-sim -m examples/hospital.py --mode visualization\n```\n\n### ▶️ Running a single replication\n\nRuns **one complete replication run**, with full tracing, reporting, plots, and diagnostics.\n\n```bash\ndesk-sim -m examples/hospital.py --mode single\n```\n\n---\n\n### 📊 Running the full simulation (multiple replications)\n\nRuns **multiple independent replications**, aggregates results, and computes confidence intervals and statistical analysis.\n\n```bash\ndesk-sim -m examples/hospital.py --mode replications\n```\n\n---\n\n### 🧪 Factorial analysis\n\nRuns a **factorial experiment**, varying model parameters and analyzing main and interaction effects.\n\n```bash\ndesk-sim -m examples/hospital.py --mode factorial\n```\n\n\n---\n## 🔬 Validation \u0026 Verification\n\nDESK includes:\n\n* Stability checker (utilization ρ \u003c 1)\n* Little’s Law analysis\n* Resource consistency validation\n* Automated warm-up suggestion\n\n---\n\n## 🛠️ Requirements\n\n* Python \u003e= 3.10\n* simpy == 4.1.1\n* numpy == 2.2.6\n* pandas == 2.3.1\n* scipy == 1.15.3\n* matplotlib == 3.10.5\n\n**Optional (for process mining):**\n\n* R \u003e= 4.0\n* BupaR\n* processanimateR\n\nThe resulting event-log .csv file is stored in result/ folder, e.g., `hospital_event_log.csv` file, to produce the animation below. The R code of the example (`hospital_bupar.R`) is available in r_animation/ folder.\n\n---\n![ProcessAnimateR](figs/hospital-processanimateR.gif)\n\n\n---\n## DESK Distribution Fitting Tool (Desk-DistFit)\n\n### 📊 Input Analysis with Desk-DistFit\n\n*How were the input models used in the previous example, such as `random.expovariate(1/10)` or `random.uniform(5, 10)`, derived from empirical data?*\n\nDesk DistFit (`desk-distfit`) is a Python tool for fitting probability distributions to empirical data using statistical tests. Inspired by previous works [6,7], this tool helps identify the best-fitting probability distribution from a set of common distributions and provides Python code for generating random numbers from the fitted distribution to DESK models. \n\nWithin DESK, `desk-distfit` addresses this question by performing *statistical input analysis*, identifying the probability distribution that best fits observed data and replacing generic assumptions with data-driven, statistically validated simulation inputs.\n\n`desk-distfit` is the official DESK input-analysis CLI for statistically fitting probability distributions to empirical data. \n\n*DESK adopts a verb-oriented command-line interface, where simulation tasks are expressed as structured actions (`desk-distfit`), ensuring consistency, reproducibility, and ease of learning across the framework.*\n\n## Features\n\n- **Multiple Distribution Support**: Tests 9 common probability distributions (uniform, triangular, exponential, normal, lognormal, beta, gamma, Weibull)\n- **Statistical Testing**: Uses Kolmogorov-Smirnov test for goodness-of-fit assessment\n- **Command-Line Interface**: Easy-to-use CLI with comprehensive options\n- **Multiple Output Formats**: Results can be saved as table, CSV, or JSON\n- **Visualization**: Generates comparative plots of fitted distributions\n- **Python Code Generation**: Automatically generates Python code for the best-fitting distribution\n- **Robust Error Handling**: Comprehensive error handling and logging\n\n**Output includes:**\n\n* Goodness-of-fit statistics\n* Best-fit distribution\n* Parameter estimates\n* Ready-to-use Python code for DESK models, such as the texts `random.expovariate(1/10)` or `random.uniform(5, 10)`.\n\n## Usage\n\n### Basic Usage\n\nFit probability distributions to empirical data:\n\n```bash\n# Basic usage\ndesk-distfit -d input_data/foo.txt\n\n# Custom significance level\ndesk-distfit -d input_data/foo.txt -a 0.01\n\n# Test specific distributions\ndesk-distfit -d input_data/foo.txt --distributions norm expon gamma\n\n# Save results\ndesk-distfit -d input_data/foo.txt -o results.txt --format json\n\n# Skip plotting\ndesk-distfit -d input_data/foo.txt --no-plot\n\n# Help\ndesk-distfit -h\n```\n\n\n### Command-Line Options\n\n| Option | Description | Default |\n|--------|-------------|---------|\n| `-d, --data` | Path to data file (required) | - |\n| `-a, --alpha` | Significance level for statistical tests | 0.05 |\n| `-b, --bins` | Number of histogram bins | 50 |\n| `--distributions` | Specific distributions to test | All |\n| `--no-plot` | Skip generating plots | False |\n| `--show-all` | Show all distributions in plot | False |\n| `-o, --output` | Output file path | None |\n| `--format` | Output format (table/csv/json) | table |\n| `-v, --verbose` | Enable verbose logging | False |\n| `-h, --help` | Show help message | - |\n\n### Examples\n\n```bash\n# Basic analysis\ndesk-distfit -d input_data/foo.txt\n\n# Custom significance level\ndesk-distfit -d input_data/foo.txt -a 0.01\n\n# Test specific distributions only\ndesk-distfit -d input_data/foo.txt --distributions norm expon gamma\n\n# Save results to file\ndesk-distfit -d input_data/foo.txt -o results.txt\n\n# Generate CSV output\ndesk-distfit -d input_data/foo.txt -o results.csv --format csv\n\n# Skip plotting (useful for batch processing)\ndesk-distfit -d input_data/foo.txt --no-plot\n\n# Show all fitted distributions in plot\ndesk-distfit -d input_data/foo.txt --show-all\n\n# Verbose output for debugging\ndesk-distfit -d input_data/foo.txt -v\n\n# Complete example with multiple options\ndesk-distfit -d input_data/foo.txt -a 0.01 -b 100 --show-all -o results.json --format json -v\n```\n\n## Input Data Format\n\nThe input file should contain one numeric value per line:\n\n```\n1.234\n2.567\n0.891\n3.456\n...\n```\n\n**Supported formats:**\n- Plain text files (.txt)\n- One number per line\n- UTF-8 encoding\n- Blank lines are ignored\n\n## Supported Distributions\n\n| Distribution | Python Random Function | Parameters |\n|-------------|------------------------|------------|\n| Uniform | `random.uniform(a, b)` | a, b |\n| Triangular | `random.triangular(low, high, mode)` | low, high, mode |\n| Exponential | `random.expovariate(lambd)` | lambda |\n| Normal | `random.gauss(mu, sigma)` | mu, sigma |\n| Log-Normal | `random.lognormvariate(mu, sigma)` | mu, sigma |\n| Beta | `random.betavariate(alpha, beta)` | alpha, beta |\n| Gamma | `random.gammavariate(alpha, beta)` | alpha, beta |\n| Weibull (Min) | `random.weibullvariate(alpha, beta)` | alpha, beta |\n| Weibull (Max) | `random.weibullvariate(alpha, beta)` | alpha, beta |\n\n## Output\n\n### Console Output\n\nThe tool provides:\n1. **Data statistics** (sample size, mean, std dev, min, max)\n2. **Distribution fitting results** with p-values and significance indicators\n3. **Parameter details** for all fitted distributions\n4. **Summary report** with best-fitting distribution\n5. **Python code** for generating random numbers for DESK model.\n\n### Example Output\n\n```\nData Statistics:\nSample size: 200\nMean: 2.0156\nStd Dev: 2.0298\nMin: 0.0089\nMax: 11.2445\n\nItem Distribution   Statistic   P-value     Significant\n------------------------------------------------------------\n1    expon          0.0456      0.8234      (*)\n2    gamma          0.0523      0.7891      (*)\n3    norm           0.0789      0.4567      \n...\n\nDistribution Fitting Summary Report\n==================================================\n\nBest Fitting Distribution: expon\n- Parameters: loc=0.000, scale=2.016\n- P-value: 0.8234\n- Significant at α=0.05: Yes\n\nPython Random Code:\nrandom.expovariate(0.496)\n```\n\n### File Output Formats\n\n#### Table Format (default)\nHuman-readable text format with detailed results and parameters.\n\n#### CSV Format\n```csv\nDistribution,P_value,Statistic,Significant,Python_Code\nexpon,0.823400,0.045600,Yes,random.expovariate(0.496)\ngamma,0.789100,0.052300,Yes,random.gammavariate(1.024,0.496)\n...\n```\n\n#### JSON Format\n```json\n{\n  \"summary\": {\n    \"sample_size\": 200,\n    \"best_distribution\": \"expon\",\n    \"alpha\": 0.05\n  },\n  \"results\": [\n    {\n      \"distribution\": \"expon\",\n      \"p_value\": 0.8234,\n      \"statistic\": 0.0456,\n      \"parameters\": {\"loc\": 0.0, \"scale\": 2.016},\n      \"significant\": true,\n      \"python_code\": \"random.expovariate(0.496)\"\n    }\n  ]\n}\n```\n\n## Interpretation\n\n### P-Values\n- **p ≥ α**: Distribution is a good fit (significant)\n- **p \u003c α**: Distribution is not a good fit (reject)\n- Higher p-values indicate better fits\n\n### Significance Indicators\n- **(*) asterisk**: Indicates significant fit at the chosen α level\n- Results are sorted by p-value (best fit first)\n\n\n\n## Statistical Method\n\nThe tool uses the **Kolmogorov-Smirnov test** [8] to assess goodness-of-fit:\n\n1. **Null Hypothesis (H₀)**: The data follows the tested distribution\n2. **Alternative Hypothesis (H₁)**: The data does not follow the tested distribution\n3. **Test Statistic**: Maximum difference between empirical and theoretical CDFs\n4. **Decision Rule**: Reject H₀ if p-value \u003c α\n\n## Limitations\n\n- **Sample Size**: Requires sufficient data points (recommended: n ≥ 30)\n- **Distribution Assumptions**: Only tests common continuous distributions\n- **Parameter Estimation**: Uses Maximum Likelihood Estimation (MLE)\n- **Independence**: Assumes data points are independent\n- **Stationarity**: Assumes data comes from a stationary process\n\n\n### Help (DESK and DESK-DistFit)\n\n```bash\n# Show detailed help\ndesk-sim -h\ndesk-distfit -h\n\n# Enable verbose output for debugging\ndesk-distfit -d input_data/foo.txt -v\n```\n\n### Development Setup\n\n```bash\n# Clone the repository\ngit clone https://github.com/joaoflavioufmg/desk.git\n\n# Create virtual environment\npython -m venv venv\nsource venv/bin/activate  # On Windows: venv\\Scripts\\activate\n\n# Install development dependencies\ncd desk\npip install .\n\n# Run tests\npytest \n```\n\n## References\n[1] Banks, J. (2005). Discrete event system simulation. Pearson Education India.\n\n[2] Law, A. M., Kelton, W. D., \u0026 Kelton, W. D. (2007). Simulation modeling and analysis (Vol. 3). New York: Mcgraw-hill. ISBN10: 0073401323 | ISBN13: 9780073401324 https://www.mheducation.com/highered/product/simulation-modeling-and-analysis-law.html?viewOption=instructor\n\n[3] Matloff, N. (2008). Introduction to discrete-event simulation and the simpy language. Davis, CA. Dept of Computer Science. University of California at Davis. Retrieved on August, 2(2009), 1-33. https://heather.cs.ucdavis.edu/matloff/public_html/156/PLN/DESimIntro.pdf\n\n[4] Kleijnen, J. P. (2015, September). Design and analysis of simulation experiments. In International workshop on simulation (pp. 3-22). Cham: Springer International Publishing. https://doi.org/10.1007/978-3-319-76035-3_1\n\n[5] Stodden, Victoria, Marcia McNutt, David H. Bailey, et al. 2016. “Enhancing Reproducibility for Computational Methods.” Science 354 (6317). https://doi.org/10.1126/science.aah6168.\n\n[6] Distribution fitting with Python: https://medium.com/@amirarsalan.rajabi/distribution-fitting-with-python-scipy-bb70a42c0aed\n\n[7] https://fitter.readthedocs.io/en/latest/\n\n[8] Massey Jr, F. J. (1951). The Kolmogorov-Smirnov test for goodness of fit. Journal of the American statistical Association, 46(253), 68-78.\n\n## Changelog\n\n### Version 1.1.2\n- Complete rewrite DESK CLI interface\n- Complete rewrite DESK-DistFit CLI interface\n\n\n### Version 1.1.0\n- Complete rewrite with object-oriented design\n- Added command-line interface\n- Multiple output formats support\n- Enhanced error handling and logging\n- Improved visualization\n\n### Version 1.0.0\n- Initial release\n- Basic distribution fitting functionality\n- Simple plotting capabilities\n---\n\n## 🤝 Contributing\n\nContributions are welcome:\n\n1. Fork the repository\n2. Create a feature branch\n3. Commit your changes\n4. Open a Pull Request\n\n---\n\n## 📄 License\n\nGPL-3.0 License — see `LICENSE` file.\n\n- The DESK documentation are licensed under Creative Commons\n\nAttribution 4.0 (CC BY 4.0).\n\n---\n\n## 👨‍🏫 Acknowledgements\n\n**Author:** Prof. João Flávio de Freitas Almeida \u003cjoao.flavio@dep.ufmg.br\u003e\n\n**Graduate Program:** PPGEP — UFMG (Brazil)\n\n**Course:** Simulating Logistics Systems\n\n**Credits:**\n* SimPy (Python)\n* bupaR, processAnimate (R)\n\n---\n\n## 📚 Citation\n\nIf you use DESK in academic work, please cite:\n\n```bibtex\n@software{desk2025,\n  author = {Almeida, João Flávio de Freitas},\n  title = {DESK: Discrete Event Simulation Kit},\n  year = {2025},\n  institution = {PPGEP-UFMG},\n  url = {https://github.com/joaoflavioufmg/desk}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoaoflavioufmg%2Fdesk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoaoflavioufmg%2Fdesk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoaoflavioufmg%2Fdesk/lists"}