Skip to content

fmartelg/FermiApp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

23 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Fermi Calculator

Version

Ask DeepWiki

A Textual TUI application for performing Fermi estimations with uncertainty quantification using Monte Carlo simulation.

Screenshot

Inspired by and based on Nuรฑo Sempere's fermi CLI calculator.

Features

  • ๐ŸŽฒ Monte Carlo Simulation: 100,000 samples for robust uncertainty quantification
  • ๐Ÿ“Š Uniform Distributions: Use min max syntax 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

Installation

Prerequisites

  • Python 3.8 or higher
  • pip package manager

Setup

# 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.txt

Dependencies

  • textual - Modern TUI framework
  • numpy - Numerical computing for Monte Carlo simulation

Usage

Run the calculator:

python fermi.py

Basic Example

# Simple scalar calculation
population = 2.7M
households = population / 2.5

Result:

population = 2.7M
=> 2.70M

households = population / 2.5
=> 1.08M

Uncertainty Example: MBA Enrollment Marketing Campaign

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.

Syntax Guide

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

Documentation

Development

Project Structure

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

Running Tests

# Run test suite
pytest tests/

# Run with coverage
pytest --cov=fermi_engine --cov=fermi_parser --cov=fermi_formatter --cov=fermi tests/

Roadmap

  • 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

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests. Here's how.

Issues? GitHub Issues

Credits

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.

Acknowledgments

  • Nuรฑo Sempere for the original fermi calculator concept
  • The Textual framework team for the excellent TUI library
  • The Python scientific computing community

License

MIT License - See LICENSE.md for details.


Made with AI for better Fermi estimations

About

Terminal-based Fermi calculator with uncertainty quantification: Make better back-of-the-envelope calculations

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages