Skip to content

Releases: brotto/crng

v0.2.1 — Cross-Domain Catastrophic Event Validation

Choose a tag to compare

@brotto brotto released this 30 Mar 11:35

CRNG v0.2.1 — Cross-Domain Catastrophic Event Validation

What's New

CRNG extreme events have been validated against 125 years of real catastrophic events across three domains: seismology, finance, and natural disasters.

Catastrophic Events Experiment

Data: 82 catastrophic events (1900-2025)

  • 39 earthquakes (M ≥ 6.7)
  • 19 financial crashes
  • 24 natural disasters

Method: Kolmogorov-Smirnov test comparing gap distributions between CRNG extreme K windows and real catastrophic event spacing.

Result: 20/20 MATCH

Real Dataset Best CRNG Match KS p-value
Earthquakes K ≥ 8 0.990
Natural Disasters K ≥ 8 0.979
All Catastrophes K ≥ 15 0.880
Financial Crashes K ≥ 5 0.665

Hidden Periodicity

FFT analysis reveals quasi-periodic structure in catastrophic event gaps:

  • All catastrophes combined: dominant period = 78 gaps, power ratio = 5.46x (above 3x significance threshold)
  • CRNG K≥10: power ratio = 4.59x
  • CRNG K≥15: power ratio = 4.81x

Metric Match

Metric Earthquakes CRNG K≥10
CV (gap regularity) 0.769 0.754
ACF (momentum) 0.127 0.109
Hurst exponent 0.776

Previous Validations

  • Financial markets: 42/49 metrics matched (86%) across 7 assets, 5 years — v0.2.0
  • Regime detection: CALM/NORMAL/STRESSED/CRISIS classification via sliding-window calibration

New Experiments

All code in experiments/:

  • coincidence_field.py — Coincidence of two independent fields of becoming
  • recursive_potentiality.py — Structured potentiality (CRNG feeding CRNG)
  • catastrophic_events.py — Cross-domain catastrophic event validation

Install

pip install crng

The Philosophical Foundation

CRNG models randomness as contingent encounters between independent oscillatory processes. The key finding: extreme events across all domains — financial, seismic, meteorological — follow the same temporal distribution because they arise from the same mechanism: interference between potentialities crossing a critical amplification threshold.

The gap distributions are domain-invariant. A financial crash and an earthquake are, statistically, the same phenomenon seen from different angles.

v0.4.0 — CRNG-Fragility Monitor

Choose a tag to compare

@brotto brotto released this 07 Apr 13:49

CRNG-Fragility Monitor -- Detecting Seneca Cliffs in Global Markets

CRNG v0.4.0 -- Systemic Fragility Detection

What's New

CRNG fat-tail analysis has been applied to 15 commodities and financial indicators across four systemic tiers. The result: current market conditions (April 2026) show kurtosis levels 2x higher than COVID-19 and 10x higher than the 2008 GFC -- a statistical signature consistent with systems approaching a Seneca Cliff.

Motivation

Inspired by Steve Keen's analysis of Strait of Hormuz vulnerability. The CRNG approach does not attempt to model the mechanics of geopolitical disruption. Instead, it detects the statistical signature of systems accumulating stress -- fat tails in daily returns that precede catastrophic collapse.

Monitored Assets (4 Tiers)

Tier Name Assets
Tier 1 Choke Point Brent, WTI, NatGas (Hormuz-dependent)
Tier 2 Financial Stress VIX, Gold, DXY, US 10Y Yields
Tier 3 Physical Economy SOX (Semiconductors), S&P 500
Tier 4 AI Bubble NASDAQ, NVDA, MSFT, META

Method

  • Rolling kurtosis (60-day window) on daily log-returns for each asset
  • Z-scores relative to each asset's historical baseline
  • Fat-tailed confidence intervals (not Gaussian) for anomaly detection
  • Concurrence detection across Tier 1 assets (Hormuz chokepoint stress)
  • Alert system: GREEN (normal) -> YELLOW (elevated) -> ORANGE (high) -> RED (critical), triggered by concurrent stress + kurtosis thresholds

Key Finding: Unprecedented Fat Tails (April 2026)

Average kurtosis across 5 key commodities = +9.05

Period Avg Kurtosis Context
April 2026 +9.05 Current readings
COVID-19 (2020) +4.58 Global pandemic
GFC (2008) +0.94 Lehman Brothers collapse

Current levels are 2x COVID and 10x GFC.

Individual Asset Readings

Asset Kurtosis Z-Score Status
NATGAS_US +16.47 -- Extreme (unprecedented in any historical crisis)
GOLD +7.39 -- Critical (safe haven rush, $4,694/oz)
BRENT +6.43 -- Critical
MSFT +7.13 -- Critical (AI bubble fat tails)
WTI +4.67 +2.20 Stressed (above confidence interval)
META +3.75 -- Elevated (AI bubble fat tails)

Natural Gas kurtosis at +16.47 has no precedent in any historical crisis window in our database (back to 1990).

What Fat Tails Mean

A kurtosis of +16 does not mean prices are high or low. It means the distribution of daily changes has extreme outliers -- the system is producing moves that should be astronomically rare under normal conditions. This is the statistical fingerprint of a system under structural stress, where small perturbations can cascade into large regime shifts (the Seneca Cliff pattern: slow buildup, rapid collapse).

Architecture

fragility_monitor/
  collector.py       -- Yahoo Finance + FRED data collection
  analyzer.py        -- CRNG metrics (rolling kurtosis, Z-scores, CI)
  create_visuals.py  -- Automated chart generation
  data/
    fragility.db     -- SQLite (S&P 500 since 1927, VIX since 1990)

Reproduce

cd crng-package/fragility_monitor
pip install yfinance fredapi pandas scipy matplotlib
python3 collector.py --days 365
python3 analyzer.py --report
python3 analyzer.py --backtest

Backtest Validation

The CRNG-Fragility framework was backtested against known crisis periods. Elevated kurtosis concurrence across tiers correctly flags:

  • 2008 GFC (financial stress precedes equity collapse)
  • 2020 COVID (energy + volatility spike simultaneously)
  • 2022 Ukraine/energy crisis (Tier 1 choke point stress)

In each case, the fat-tail signature appeared before the peak drawdown, not after.

Implication

Standard risk models (VaR, portfolio variance) assume thin-tailed return distributions. When kurtosis across multiple asset classes simultaneously exceeds historical crisis levels, these models systematically underestimate tail risk. The CRNG-Fragility Monitor provides a complementary signal: not a prediction of what will happen, but a measurement of how far the system has drifted from its baseline statistical regime.

Data sources (verifiable):

v0.3.0 — Weather Prediction + Lorenz Attractor

Choose a tag to compare

@brotto brotto released this 05 Apr 14:37

What's New

CRNG validated against 10 years of real weather data and tested on Lorenz strange attractors.

Weather Prediction Experiment

Data: 10 years daily temperature (2014–2023), ERA5 reanalysis (ECMWF), 3 cities.

Key Result — Kurtosis Match 3/3:

City Real K PRNG K CRNG K
São Paulo 6.39 2.99 6.45
New York 4.71 2.99 5.79
London 4.98 2.99 5.57

PRNG always produces K ≈ 3.0 (Gaussian). CRNG captures real fat-tailed climate variability.

Distribution scorecard: CRNG wins 5/6 metrics (83%)

Forecast MAE: CRNG wins 4/5 horizons in São Paulo (fattest tails). Mixed in seasonal climates.

Lorenz Attractor Experiment

CRNG preserves chaotic dynamics better than PRNG:

  • Vol clustering: CRNG 0.996 ≈ Deterministic 0.997 >> PRNG 0.990
  • Regime changes: CRNG 289 < PRNG 338 (fewer artificial transitions)

Data Sources (verifiable)

  • Open-Meteo Historical API (ERA5, CC BY 4.0)
  • NOAA GHCN-Daily
  • NOAA ISD

Reproduce

pip install crng
python experiments/weather_prediction.py
python experiments/lorenz_attractor.py

v0.2.0 — from_data() + Real-World Validation (86%)

Choose a tag to compare

@brotto brotto released this 27 Mar 23:11

CRNG v0.2.0 — Contingency Random Number Generator

The Story Behind CRNG

I refused to believe in the Law of Large Numbers. Not that it's wrong — but that it describes reality.

That stubbornness led me to build a random number generator that reproduces 86% of real financial market signatures. Standard PRNGs reproduce 14%.

How it started

It began in January 2026 investigating whether Brazil's Mega-Sena lottery was rigged. I built an Arduino circuit for true hardware randomness (thermal noise from the ADC) and measured both using 6 temporal-dynamic metrics anchored on Permutation Entropy (PE):

  • Arduino (physics): PE = 0.998
  • US Mega Millions: PE = 0.999
  • Brazil's Mega-Sena: PE = 0.488

The Mega-Sena has half the ordinal complexity of genuine randomness across 30 years of data.

The Kurtosis Discriminant

In a parallel project analyzing synthetic trading indices (50,000 ticks, 10 symbols, 11 statistical tests), I discovered a clean binary classifier:

  • Every PRNG ever built: K = 3.0
  • Every real market ever measured: K >= 5

Zero overlap. Gold K=9.26, Ethereum K=22.85, Bitcoin K=218.73. NumPy, Mersenne Twister, PCG, xoshiro — always K=3.0.

The Philosophical Core

The LLN doesn't describe what happens. It describes what can happen. It describes potentiality — δύναμις (dynamis) — not actuality (ενέργεια).

PRNGs obey the LLN perfectly because they are random variables — pure mathematical objects. They embody Parmenides: "Being is." But real phenomena embody Heraclitus: "Everything flows" (πάντα ῥεῖ).

A spinning coin is pure becoming. It is neither heads nor tails until cut by measurement at a contingent instant.

The Spinning Coins Experiment

Sine oscillators with irrational frequencies (π, e, φ, √primes) as "spinning coins." A second set as "blades." Their contingent encounter produces results with:

  • Binary outputs: perfectly random (ACF = 0.002)
  • Coupling intensities: K = 3.46, vol clustering ACF = 0.281 (Gold's = 0.269)

The Phase Transition

Amplitude cascades revealed a phase transition:

Amplification Kurtosis
0.0 3.4 (Gaussian)
1.0 4.2 ← critical threshold
2.0 123
10.0 521

Not a smooth curve. Below: Gaussian. Above: fat tails self-amplify. Real markets operate just above the critical point.


What's New in v0.2.0

from_data() — Auto-Calibrate from Real Data

from crng import from_data

# Pass prices or returns — CRNG auto-calibrates
rng = from_data(my_price_series, seed=42)
synthetic = rng.generate(10000)

Uses iterative calibration to match target kurtosis and vol clustering from your data.

Real-World Validation

Tested against 7 assets, 5 years, 7 metrics, 10 seeds:

Asset Real K CRNG K NumPy K CRNG Score
Gold 15.6 11.2 3.0 6/7
S&P 500 9.6 8.4 3.0 6/7
ETH 8.2 8.5 3.0 7/7
BTC 6.9 7.3 3.0 7/7
Oil 6.4 8.5 3.0 6/7
USDJPY 6.0 5.1 3.0 5/7
EURUSD 4.9 3.1 3.0 5/7

CRNG: 42/49 (86%) — NumPy: 7/49 (14%)

Expanded Test Suite

25 tests covering determinism, kurtosis ordering, vol clustering, entropy, from_data validation, fat tails vs PRNG, and kurtosis capture verification.


Installation

pip install crng

Quick Start

from crng import gold, from_data, ContingencyRNG

# Preset
rng = gold(seed=42)
xs = rng.generate(1000)

# Auto-calibrate from data
rng = from_data(my_prices, seed=42)

# Custom
rng = ContingencyRNG(seed=42, target_kurtosis=15.0, vol_clustering=0.3)

Assets

  • CRNG Demo Video — 80s visual explainer of the algorithm and results
  • Oscillator Simulation — The spinning coins experiment in action
  • Python packages — wheel and source distribution

"Reality is local. Reality is contingent. Reality is Heraclitean."