Files
fn_registry/python/functions/datascience/estimate_hawkes.md
T
egutierrez 63a9cb5273 feat: funciones Python datascience, finance, cybersecurity y pipelines
Datascience: aggregate_by_group, deduplicate_entities/relations, detect_drift,
diff_entities/relations, extract_entities/relations_llm, hotness_score, melt,
merge_graphs, pivot, build_entity/relation_schema_prompt.
Finance: avellaneda_stoikov_quotes, generate_gbm_prices, generate_taker_order,
hawkes_intensity + módulo finance.py.
Cybersecurity: envelope_encrypt/decrypt + módulo cybersecurity.py.
Pipelines: extraction_pipeline, monte_carlo_market, run_market_sim.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-05 17:11:32 +02:00

37 lines
1.2 KiB
Markdown

---
name: estimate_hawkes
kind: function
lang: py
domain: datascience
version: "1.0.0"
purity: pure
signature: "def estimate_hawkes(arrivals: list[int], max_lag: int = 30) -> dict"
description: "Estima parámetros de un proceso Hawkes (alpha, beta, branching_ratio) desde la autocorrelación de arrivals ajustando una exponencial decreciente sobre la ACF."
tags: [estimation, hawkes, stochastic-process, microstructure, timeseries]
uses_functions: []
uses_types: []
returns: []
returns_optional: false
error_type: ""
imports: [numpy, scipy]
tested: false
tests: []
test_file_path: ""
file_path: "python/functions/datascience/datascience.py"
---
## Ejemplo
```python
arrivals = [0, 1, 3, 2, 0, 1, 4, 2, 1, 0] * 10
result = estimate_hawkes(arrivals, max_lag=10)
# {'alpha': 0.312, 'beta': 0.874, 'branching_ratio': 0.357, 'acf': [...]}
```
## Notas
Ajusta la función `a * exp(-b * lag)` sobre los lags 1..max_lag de la ACF usando `curve_fit` de scipy.
Si el primer lag de la ACF es <= 0.01 (sin autocorrelación), retorna alpha=0, beta=1, branching_ratio=0.
El branching_ratio = alpha/beta; si se acerca a 1, el proceso es explosivo.
Función pura: requiere numpy y scipy instalados.