DataScience / README.md
MartialTerran's picture
Update README.md
52ee684 verified
|
Raw History Blame Contribute Delete
6.12 kB
metadata
license: apache-2.0
tags:
  - mathematics
  - pi
  - hexadecimal
  - synthetic-data
  - pseudorandomness
  - sequence-modeling
  - transformers
task_categories:
  - text-generation
  - tabular-to-text
size_categories:
  - 1M<n<10M

π Hexadecimal Repetition & Entropy Analysis Suite

A data science testbed and synthetic dataset generator examining the distribution, collision statistics, and pseudorandom sequence properties of π in hexadecimal (Base 16).

This repository explores the limits of sequence modeling, token predictability, and structural entropy in mathematically generated sequences—specifically testing whether modern Autoregressive Transformers and Large Language Models (LLMs) can discover latent structure in mathematically deterministic yet pseudorandom streams.


📌 Research Motivation: Can LLMs Learn π?

Core Hypothesis:
Can an ML model or LLM detect patterns in an arbitrary sequence of hexadecimal numerals of π and predict the subsequent digits? Modern mathematics defines π as an irrational constant (~3.14159…), and its exact value cannot be expressed as a simple fraction like 22/7.

The 22/7 approximation is a practical fraction used in some contexts, but it is less accurate than 355/113.

Because π is conjectured to be a normal number in Base 16, its fractional expansion exhibits statistical properties virtually indistinguishable from an ideal pseudorandom sequence. Evaluating models on this data serves several key machine learning and data science purposes:

  1. Synthetic Sequence Probing: Testing the inductive biases and context-window dynamics of Transformers on truly non-periodic streams.
  2. Memorization vs. Generalization: Evaluating whether models are merely memorizing known chunks of π or attempting to synthesize algorithmic computation.
  3. Entropy & Compressibility: Verifying that substring repetition frequencies conform to expected random walk and birthday-problem bounds rather than compressible tokens.

🚀 Key Features of Pi_Hex_DataScience_V1.0.py

The repository includes a self-contained, high-performance Python engine designed to generate and audit Base 16 digits of π:

  • Fast Chudnovsky Binary-Splitting Engine: Pure Python arbitrary-precision integer arithmetic optimized for standard CPUs (zero external dependencies like gmpy2 required).
  • Exhaustive Substring Collision Engine: Scans for exact sequence repetitions across configurable length horizons ($L \in [4, 64]$).
  • Exponential Horizon Doubling: Automatically doubles the search horizon $N$ when no collisions are detected for target sequence lengths.
  • Detailed Telemetry: Tracks incident coordinates ($i_1, i_2$), distances ($\Delta$), and generates 0–F digit distribution histograms for repeating sequences.
  • Safety & Persistence: Checkpoints progress every 30 minutes, supports auto-download within Google Colab, and enforces an optional hard runtime ceiling (default: 3 hours).

📁 Repository Structure

├── Pi_Hex_DataScience_V1.0.py     # Core generation & collision engine
├── pi_datascience_checkpoint.json # Saved state & intermediate analysis
├── pi_repetition_report.txt       # Plaintext summary table
├── pi_repetition_report.md        # Markdown report with collision coordinates
├── pi_repetition_report.html      # Interactive HTML report with mini histograms
└── README.md                      # Dataset card & documentation

🛠️ Usage Quickstart

1. Requirements

The script uses standard library modules only:

python --version  # Python 3.8+ recommended

2. Run the Analysis

python Pi_Hex_DataScience_V1.0.py

3. Google Colab Support

The script includes built-in detection for Google Colab environments (sys.modules["google.colab"]). When run in Colab, intermediate checkpoints and reports (.json, .txt, .md, .html) are automatically downloaded to your local machine every 30 minutes.


⚙️ Configuration Parameters

The generation horizon and substring lengths can be modified directly inside CONFIG:

CONFIG = {
    "min_length": 4,                  # Smallest substring length to inspect
    "max_length": 64,                 # Longest substring length to inspect
    "initial_n": 2000,                # Initial digit search horizon (N)
    "max_n_limit": 2000000,           # Safety limit (2 million hex digits)
    "checkpoint_interval_sec": 1800,  # 30-minute state checkpointing
    "max_runtime_sec": 10800,         # 3-hour runtime budget ceiling
    "checkpoint_file": "pi_datascience_checkpoint.json",
    "report_txt": "pi_repetition_report.txt",
    "report_md": "pi_repetition_report.md",
    "report_html": "pi_repetition_report.html",
}

📊 Sample Report Output

When executed, the engine outputs structured reports summarizing whether sequences of length $L$ have repeated within the search window:

Length ($L$) Repeat Detected? Unique Repeats First Repeated Sequence First Index ($i_1$) Repeat Index ($i_2$) Distance ($\Delta$)
4 YES 12 2B4C 148 892 744
5 YES 1 A0E18 420 1850 1430
6 NO 0 — — — —

(If repeats are absent, the engine automatically doubles the search window $N \to 2N$ and re-evaluates until collision thresholds are met or limits are reached).


🔬 Use Cases in Machine Learning

  • Next-Token Prediction Baselines: Use hex sequences of π as a negative control benchmark against autoregressive sequence models.
  • Tokenizer Stress Testing: Evaluate how Byte-Pair Encoding (BPE) and subword tokenizers partition high-entropy, non-repeating alphanumeric series.
  • Synthetic Pretraining Experiments: Measure whether exposure to algorithmic number-theoretic streams affects transformer attention entropy.

📜 License

This Pi-Hex dataset is distributed under the Apache 2.0 License.