A Textual TUI application for performing Fermi estimations with uncertainty quantification using Monte Carlo simulation.
Inspired by and based on Nuรฑo Sempere's fermi CLI calculator.
- ๐ฒ Monte Carlo Simulation: 100,000 samples for robust uncertainty quantification
- ๐ Uniform Distributions: Use
min maxsyntax for uncertain quantities - ๐ข Number Suffixes: Support for K (thousand), M (million), B (billion) notation
- ๐ Percentile Output: Displays P10, P50 (median), and P90 values
- ๐จ Modern TUI: Two-panel Textual interface with real-time updates
- ๐งฎ Mathematical Operations: Standard arithmetic (+, -, *, /, ^)
- ๐พ Variable Storage: Define and reference variables across calculations
- โก Instant Results: Calculate with F5 or click the Calculate button
- Python 3.8 or higher
- pip package manager
# Clone the repository
git clone https://github.com/fmartelg/FermiApp.git
cd FermiApp
# Create and activate a virtual environment
python -m venv venv
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
# source venv/bin/activate
# Install dependencies
pip install -r requirements.txttextual- Modern TUI frameworknumpy- Numerical computing for Monte Carlo simulation
Run the calculator:
python fermi.py# Simple scalar calculation
population = 2.7M
households = population / 2.5
Result:
population = 2.7M
=> 2.70M
households = population / 2.5
=> 1.08M
tam = 45M 55M # Total addressable market
aware_rate = 0.30 0.50 # See online ad
interest_rate = 0.10 0.20 # Click on ad
consideration_rate = 0.40 0.60 # Visit MBA program detail page
intent_rate = 0.15 0.30 # Visit enrollment page
conversion_rate = 0.50 0.70 # Complete enrollment
aware = tam * aware_rate
interest = aware * interest_rate
consideration = interest * consideration_rate
intent = consideration * intent_rate
enrollments = intent * conversion_rate
Result:
tam = 45M 55M # Total addressable market
=> 46.00M 50.02M 54.00M (P10, P50, P90)
aware_rate = 0.30 0.50 # See online ad
=> 0.32 0.40 0.48 (P10, P50, P90)
interest_rate = 0.10 0.20 # Click on ad
=> 0.11 0.15 0.19 (P10, P50, P90)
consideration_rate = 0.40 0.60 # Visit product detail page
=> 0.42 0.50 0.58 (P10, P50, P90)
intent_rate = 0.15 0.30 # Visit enrollment page
=> 0.17 0.22 0.28 (P10, P50, P90)
conversion_rate = 0.50 0.70 # Complete enrollment
=> 0.52 0.60 0.68 (P10, P50, P90)
aware = tam * aware_rate
=> 15.88M 19.93M 24.25M (P10, P50, P90)
interest = aware * interest_rate
=> 2.06M 2.93M 4.05M (P10, P50, P90)
consideration = interest * consideration_rate
=> 995.53K 1.45M 2.07M (P10, P50, P90)
intent = consideration * intent_rate
=> 203.18K 320.19K 495.88K (P10, P50, P90)
enrollments = intent * conversion_rate
=> 119.32K 191.48K 301.13K (P10, P50, P90)
Interpreting Results:
The output shows three key percentiles from the Monte Carlo simulation:
- P10 (119.32K): 10% of simulated outcomes fall below this value
- P50 (191.48K): The median - half the simulations are above, half below
- P90 (301.13K): 90% of simulated outcomes fall above this value
The P10-P90 range (119K-301K) represents an 80% credible interval. You might say: "Given my current beliefs about conversion rates and market size, I estimate an 80% probability that enrollments will fall between 119K and 301K."
Important caveat: These results only reflect the uncertainties you've specified in your input ranges. If your input estimates are overconfident (ranges too narrow) or miss key factors, the output will be similarly flawed. Fermi calculations help you think systematically about uncertainty, but they're only as good as your assumptions and the beliefs they encode.
| Feature | Syntax | Example |
|---|---|---|
| Variable assignment | name = expression |
cost = 1000 |
| Uniform distribution | min max |
price = 10 20 |
| Number suffixes | K, M, B |
population = 2.7M |
| Arithmetic | +, -, *, /, ^ |
total = a * b + c |
| Comments | # |
# This is a comment |
| Variable reference | Use variable name | total = cost * quantity |
- Complete Specification - Full feature documentation
- Sprint 1 Notes - Basic calculations
- Sprint 2 Notes - Uniform distributions
FermiApp/
โโโ docs/
โ โโโ fermi-spec.md # Complete specification
โ โโโ sprints/ # Development sprint notes
โโโ tests/
โ โโโ test_engine.py # Tests for evaluation engine
โ โโโ test_formatter.py # Tests for number formatting
โ โโโ test_parser.py # Tests for expression parsing
โโโ .gitignore # Git ignore rules
โโโ fermi_engine.py # Core evaluation engine with Monte Carlo
โโโ fermi_formatter.py # Number parsing and formatting utilities
โโโ fermi_parser.py # Expression parser and tokenizer
โโโ fermi.py # Main application entry point
โโโ fermi.tcss # Textual CSS styling
โโโ LICENSE.md # MIT License
โโโ README.md # This file
โโโ requirements.txt # Python dependencies
# Run test suite
pytest tests/
# Run with coverage
pytest --cov=fermi_engine --cov=fermi_parser --cov=fermi_formatter --cov=fermi tests/- Sprint 1: Basic scalar calculations and variable references
- Sprint 2: Uniform distributions with Monte Carlo simulation
- Sprint 3: Additional distributions (normal, lognormal, beta)
- Sprint 4: File save/load functionality
- Sprint 5: Enhanced UI features and export options
Contributions are welcome! Please feel free to submit issues or pull requests. Here's how.
Issues? GitHub Issues
This project is inspired by and based on Nuรฑo Sempere's fermi CLI calculator, which provides a command-line interface for similar Fermi estimation workflows.
- Nuรฑo Sempere for the original fermi calculator concept
- The Textual framework team for the excellent TUI library
- The Python scientific computing community
MIT License - See LICENSE.md for details.
Made with AI for better Fermi estimations
