---
id: best_central_tendency_py_datascience
name: best_central_tendency
kind: function
lang: py
domain: datascience
version: "1.0.0"
purity: pure
signature: "def best_central_tendency(values: list[float], dist_type: str) -> tuple[str, float]"
description: "Selects the most appropriate central tendency measure for a given distribution type. Returns (label, value) pair."
tags: [statistics, central-tendency, distribution, robust, mean, median, pendiente-usar]
uses_functions:
  - geometric_mean_py_datascience
  - trimmed_mean_py_datascience
uses_types: []
returns: []
returns_optional: false
error_type: ""
imports: [math, numpy]
example: |
  from best_central_tendency import best_central_tendency
  label, value = best_central_tendency([1, 2, 3, 4, 5], "normal-ish")
  # ("mean", 3.0)
tested: true
tests:
  - "test_best_central_tendency_normal_ish"
  - "test_best_central_tendency_right_skewed"
  - "test_best_central_tendency_left_skewed"
  - "test_best_central_tendency_lognormal_ish"
  - "test_best_central_tendency_heavy_tail"
  - "test_best_central_tendency_empty"
  - "test_best_central_tendency_default"
test_file_path: "python/functions/datascience/tests/test_best_central_tendency.py"
file_path: "python/functions/datascience/best_central_tendency.py"
params:
  - name: values
    desc: "List of numeric values to summarize."
  - name: dist_type
    desc: "Distribution type string, typically from detect_distribution_type. One of: normal-ish, lognormal-ish, heavy-tail, right-skewed, left-skewed, other, too_few_samples."
output: >
  Tuple (label, value) where label is one of "mean", "median", "geometric_mean",
  "trimmed_mean_5%", and value is the computed central tendency. Returns ("median", math.nan) for empty input.
source_repo: "internal:footprint_aurgi"
source_license: "internal-aurgi"
source_file: "aurgi_mapas/generar_pdf_reporte.py:196"
---

## Ejemplo

```python
from best_central_tendency import best_central_tendency

best_central_tendency([1, 2, 3, 4, 5], "normal-ish")    # ("mean", 3.0)
best_central_tendency([1, 2, 3, 4, 5], "right-skewed")  # ("median", 3.0)
best_central_tendency([1, 2, 4, 8], "lognormal-ish")    # ("geometric_mean", ~2.83)
best_central_tendency([1, 2, 3, 100], "heavy-tail")     # ("trimmed_mean_5%", ...)
```

## Mapeo de tipos a medidas

| dist_type       | Medida           | Funcion interna       |
|-----------------|------------------|-----------------------|
| normal-ish      | mean             | numpy.mean            |
| lognormal-ish   | geometric_mean   | geometric_mean()      |
| heavy-tail      | trimmed_mean_5%  | trimmed_mean(0.05)    |
| right-skewed    | median           | numpy.median          |
| left-skewed     | median           | numpy.median          |
| otros / default | median           | numpy.median          |
