import React from 'react'; import { BookOpen, X, Cpu, BarChart2, Compass, ShieldAlert, Activity } from 'lucide-react'; import 'katex/dist/katex.min.css'; import { BlockMath, InlineMath } from 'react-katex'; interface CryptoMathModalProps { isOpen: boolean; onClose: () => void; } export default function CryptoMathModal({ isOpen, onClose }: CryptoMathModalProps) { React.useEffect(() => { const handleKeyDown = (e: KeyboardEvent) => { if (e.key === 'Escape') { onClose(); } }; if (isOpen) { window.addEventListener('keydown', handleKeyDown); } return () => { window.removeEventListener('keydown', handleKeyDown); }; }, [isOpen, onClose]); if (!isOpen) return null; return (
{/* Modal Header */}

Crypto Bayesian Markov - Math & Logic Specification

Institutional Specification Manual

{/* Modal Body */}

4. Crypto Bayesian Markov Engine

Models momentum regimes and updates transition probabilities using on-chain alpha inputs.

{/* Section A: Markov Chain State Space */}

A. Markov Chain State Space

The asset return state space is mapped into 3 momentum regimes:

State 1 () Bearish Squeeze / Crackdown
State 2 () Consolidation / Mean Reversion
State 3 () Parabolic Bull Run
{/* Section B: Transition Matrix (P) */}

B. Transition Matrix (P)

Calculates transition probabilities over rolling 90-day return vectors:

where represents the frequency probability of moving from State to State .

{/* Section C: Bayesian Update Engine */}

C. Bayesian Update Engine

When external alpha inputs (e.g. Funding Rate anomalies, Whale inflows) occur, state probabilities are updated using Bayes' theorem:

Where:
- is the prior state probability from the Markov transition matrix.
- is the conditional likelihood of observing this whale spike / funding squeeze in State .

{/* Section D: Two-Stage Hybrid Machine Learning Pipeline */}

D. Two-Stage Hybrid Machine Learning Pipeline

To minimize false signals and adapt to changing momentum regimes, we run a two-stage hybrid ML pipeline. First, a client-side Random Forest Classifier maps non-linear combinations of four features to forecast trend probabilities:

Ensemble Feature Inputs:
  • Funding Rates (): Measures leverage imbalance in futures contracts.
  • Open Interest Volatility (): Captures the contract buildup speed.
  • Long/Short Retail Skew (): Identifies retail sentiment extremes.
  • Whale Accumulation Inflows (): Proxy for cold-wallet transfer velocities.

The Random Forest ensemble evaluates 10 non-linear decision trees to output the short-term and medium-term trend probabilities:

{/* Section E: Conjugate Beta-Binomial Error-Correction Engine */}

E. Conjugate Beta-Binomial Error-Correction Engine

Raw ML forecasts are susceptible to regime drift. We implement a self-correcting Beta-Binomial update. The continuous probability output from the Random Forest model is mapped into a discrete Binomial likelihood by defining the Trust-Weight Hyperparameter () as the Effective Sample Size (ESS):

1. Prior Distribution (Accuracy History):

where represents historical prediction successes and represents false alarms.

2. Likelihood Formulation (Binomial pseudo-observations):

where is the number of simulated successes and is the number of simulated failures.

3. Conjugate Posterior Update:

{/* Section F: Mathematical Proof of Posterior Mean Integration */}

F. Mathematical Proof of Posterior Mean Integration

To resolve a single operational point-estimate from our posterior distribution, we integrate out the continuous parameter to calculate the mathematical expectation of the posterior distribution:

Posterior Expectation Integral Proof:

Using the definition of the Beta function and the recurrence relation :

Expanded Workstation Implementation Formula:

This formulation ensures that if the prior model is highly accurate (large ), the raw ML signal is smoothed towards historical baseline expectations. If historical errors are high, the prior variance restricts overreaction to noisy signals.

); }