How bryan-13-ty/calculadora-de-intervalos-de-confianza works
1. Overall shape
This repository is a small, single-process statistical calculator centered on confidence-interval computation. The architecture is layered around one entrypoint (main.py), a set of case modules for each interval type, and shared service/validation/visualization code under src/.
2. Entry orchestration
main.py is the top-level execution path. It likely handles the user interaction flow: selecting the interval family, collecting inputs, invoking the appropriate case logic, and presenting results. For an architecture diagram, treat this as the orchestrator/controller boundary.
3. Problem-domain modules by interval type
The casos/ package contains one module per supported confidence-interval scenario:
- media.py
- dif_medias.py
- proporcion.py
- dif_proporciones.py
- varianza.py
- coc_varianzas.py
These are the domain entry points for each statistical case. They separate the formulas and parameter requirements for each interval family.
4. Shared calculation engine
src/services/calculos.py is the central computation layer. It likely contains reusable formula functions for margins of error, critical values, and interval bounds. The casos/* modules probably call into this service rather than implementing all math inline.
5. Input validation and error handling
src/validaciones.py is the gatekeeper for user-supplied data and statistical assumptions. src/errores.py and src/advertencias.py define the project’s custom error/warning types or messages. In the architecture, place these between input collection and calculation to show that invalid sample sizes, inconsistent variances, or unsupported assumptions are rejected early.
6. Visualization/output support
src/visualization/graficas.py is a separate presentation-side component for generating interval graphics. It is likely used after computation to visualize the point estimate and confidence bounds. This is a downstream consumer of the computed interval, not part of the math core.
7. Utility and shared configuration
src/utils.py and config/config.py hold cross-cutting helpers and constants. config/ likely contains shared parameters such as confidence levels, formatting, or distribution-related settings. These modules sit at the shared infrastructure layer used by both case logic and services.
8. Repository boundaries
The project is organized into clear boundaries:
- casos/: statistical use cases
- src/services/: reusable computational logic
- src/validaciones.py + src/errores.py + src/advertencias.py: input safety and domain constraints
- src/visualization/: presentation/graphing
- config/: shared configuration
- docs/ and assets/: supporting materials, not runtime logic
9. Data flow
The typical flow is:
user input → validation → case selection → shared calculations → optional graph generation → result output.
The key architectural idea is that the case modules translate a specific statistical scenario into a standard call pattern against the shared computation layer.
10. Supported statistical domains
The README defines the supported confidence-interval families, and these map directly to the casos/ modules:
- population mean
- difference of means
- proportion
- difference of proportions
- population variance
- ratio of variances
That makes the project a statistical decision tree rather than a general-purpose analytics engine.
11. External/static assets
assets/images/ contains illustrative images for each case, and docs/formulario_Intervalos_de_confianza.pdf provides reference formulas. These are documentation/support assets rather than runtime dependencies, but they matter for understanding the educational intent and UI presentation.
12. Likely runtime model
The README says to run py main.py, which suggests a local Python application rather than a web service. No external APIs, databases, or message brokers are indicated. The main architectural concern is therefore internal module coordination, not distributed-system integration.
13. Diagram guidance
If you draw this system, center it on main.py, connect it to the six casos/ modules, then show each case calling:
- src/validaciones.py for input checks
- src/services/calculos.py for formulas
- src/visualization/graficas.py for charts
- src/errores.py / src/advertencias.py for exceptional paths
- config/config.py and src/utils.py as shared support
14. Design character
The codebase is best understood as a modular educational calculator with one level of indirection between user-facing scenarios and statistical formulas. Its main architectural strength is the separation between case-specific orchestration and shared math/validation logic.
Main entry points: calculos.py Calculations · validaciones.py Validation · main.py Main · graficas.py Graphs
Components 14
Entrypoint
Top-level runtime orchestration.
- Main · Top-level application flow and case selection.
main.py
Statistical cases
One module per confidence-interval family.
- Mean CI · Confidence interval for a population mean.
casos/media.py - Mean diff · Confidence interval for the difference of means.
casos/dif_medias.py - Proportion CI · Confidence interval for a proportion.
casos/proporcion.py - Prop diff · Confidence interval for the difference of proportions.
casos/dif_proporciones.py - Variance CI · Confidence interval for a population variance.
casos/varianza.py - Variance ratio · Confidence interval for the ratio of variances.
casos/coc_varianzas.py
Core services
Shared validation, math, and support logic.
- Calculations · Reusable statistical formulas and interval computations.
src/services/calculos.py - Validation · Checks user input and statistical assumptions.
src/validaciones.py - Errors · Custom error definitions and handling support.
src/errores.py - Warnings · Warning types or messages for non-fatal issues.
src/advertencias.py
Presentation
Output and visualization layer.
- Graphs · Interval charts and presentation graphics.
src/visualization/graficas.py
Connections 28
- Main → Mean CI: selects · Routes the user to the mean interval workflow.
- Main → Mean diff: selects · Routes the user to the difference-of-means workflow.
- Main → Proportion CI: selects · Routes the user to the proportion workflow.
- Main → Prop diff: selects · Routes the user to the difference-of-proportions workflow.
- Main → Variance CI: selects · Routes the user to the variance workflow.
- Main → Variance ratio: selects · Routes the user to the variance-ratio workflow.
- Mean CI → Validation: checks · Validates sample and confidence inputs before computing.
- Mean CI → Calculations: computes · Delegates interval formulas to the shared math layer.
- Mean diff → Validation: checks · Validates assumptions for two-sample mean intervals.
- Mean diff → Calculations: computes · Uses shared formulas for mean-difference intervals.
- Proportion CI → Validation: checks · Validates proportion inputs and constraints.
- Proportion CI → Calculations: computes · Uses shared formulas for proportion intervals.
- Prop diff → Validation: checks · Validates two-proportion assumptions and counts.
- Prop diff → Calculations: computes · Uses shared formulas for difference-of-proportions intervals.
- Variance CI → Validation: checks · Validates variance interval inputs.
- Variance CI → Calculations: computes · Uses shared formulas for variance intervals.
- Variance ratio → Validation: checks · Validates ratio-of-variances assumptions.
- Variance ratio → Calculations: computes · Uses shared formulas for variance-ratio intervals.
- Calculations → Config: reads · Consumes shared statistical settings and constants.
- Calculations → Utilities: uses · Reuses helper logic for formatting and support calculations.
- Mean CI → Graphs: renders · Produces a visualization of the computed interval.
- Mean diff → Graphs: renders · Produces a visualization of the computed interval.
- Proportion CI → Graphs: renders · Produces a visualization of the computed interval.
- Prop diff → Graphs: renders · Produces a visualization of the computed interval.
- Variance CI → Graphs: renders · Produces a visualization of the computed interval.
- Variance ratio → Graphs: renders · Produces a visualization of the computed interval.
- Validation → Errors: raises · Uses custom error types for invalid inputs.
- Validation → Warnings: warns · Emits non-fatal warnings for borderline assumptions.