SFIT Synthetic Event Data Generator — IMPROVED VERSION
- stevensondouglas91
- Mar 27
- 3 min read
"""

======================================================
Now includes **explicit KWW tail simulation** (Kohlrausch–Williams–Watts stretched exponential)
to better reproduce the 832.6 s relaxation tails with β = 1.060 observed in your ILL 3-14-412 reanalysis.
Key SFIT features embedded:
- 1.20134 mHz sinusoidal modulation ("Quantum Heartbeat")
- Phase-locked π-overshoot at t ≈ 416.65 s (half-period)
- Explicit KWW relaxation tails triggered by periodic "mirror steps"
- ~4.5 % initial post-step overshoot that decays with τ = 832.6 s, β = 1.060
- Poisson statistics with realistic counting rate
Output file: data/processed/synthetic_event_sample.dat
"""
import numpy as np
import os
from datetime import datetime
# ==================== SFIT KEY CONSTANTS (from Preprint) ====================
NU_RES = 0.00120134 # Hz — Quantum Heartbeat resonance
OMEGA_RES = 2 * np.pi * NU_RES
PERIOD = 1.0 / NU_RES # ≈ 833.3 s
HALF_PERIOD = PERIOD / 2 # ≈ 416.65 s
K_COUPLING = 1.060
TAU_KWW = 832.6 # s — KWW relaxation time
BETA_KWW = K_COUPLING # β = 1.060 (stretched exponent)
BASE_RATE = 50.0 # average events per second
MOD_AMPLITUDE = 0.00122 # ~0.122 % contrast from heartbeat
OVERSHOOT_FACTOR = 1.045 # ~4.5 % initial post-step overshoot
STEP_INTERVAL = PERIOD # mirror steps every full period
TOTAL_DURATION = 7200.0 # 2 hours — enough to see multiple KWW tails + heartbeat
# Reproducibility
np.random.seed(42)
# Track mirror-step times (KWW tails are triggered here)
step_times = []
def kww_decay(t, t_step):
"""Explicit Kohlrausch–Williams–Watts (KWW) stretched-exponential decay"""
if t <= t_step:
return 0.0
dt = t - t_step
return np.exp( - (dt / TAU_KWW) ** BETA_KWW )
def sfit_modulation(t):
"""Improved modulation: heartbeat + explicit KWW tails from mirror steps"""
# 1.20134 mHz sinusoidal heartbeat
heartbeat = MOD_AMPLITUDE * np.cos(OMEGA_RES * t)
# 2. KWW relaxation tails from all previous mirror steps
kww_contribution = 0.0
for t_step in step_times:
kww_contribution += (OVERSHOOT_FACTOR - 1.0) * kww_decay(t, t_step)
# 3. Small π-phase overshoot boost near half-period points (for extra realism)
phase = (t % PERIOD) / HALF_PERIOD
extra_overshoot = 0.0
if abs(phase - 1.0) < 0.03 or abs(phase) < 0.03:
extra_overshoot = 0.015 * np.exp(-abs(phase - 1.0) * 30)
return 1.0 + heartbeat + kww_contribution + extra_overshoot
def generate_synthetic_events():
global step_times
print("Generating SFIT synthetic event data with explicit KWW tails...")
# Schedule periodic mirror steps
step_times = np.arange(0, TOTAL_DURATION + 1, STEP_INTERVAL)
print(f"→ Scheduled {len(step_times)} mirror steps (every {PERIOD:.1f} s)")
timestamps = []
channels = []
t = 0.0
while t < TOTAL_DURATION:
rate = BASE_RATE * sfit_modulation(t)
# Poisson process for next event
dt = np.random.exponential(1.0 / max(rate, 0.1)) # avoid zero/negative rate
t += dt
if t >= TOTAL_DURATION:
break
# Detector channel (realistic qBounce-like pulse heights)
channel = int(np.random.normal(12, 3)) + 8
timestamps.append(int(t * 1e6)) # microseconds
channels.append(channel)
print(f"Generated {len(timestamps):,} events over {TOTAL_DURATION/3600:.1f} hours")
print(f" • Heartbeat at {NU_RES*1000:.5f} mHz")
print(f" • KWW tails (τ={TAU_KWW} s, β={BETA_KWW}) after each mirror step")
return np.array(timestamps), np.array(channels)
def save_synthetic_data(timestamps, channels, filename="data/processed/synthetic_event_sample.dat"):
os.makedirs(os.path.dirname(filename), exist_ok=True)
with open(filename, "w") as f:
f.write("# SFIT Synthetic Event Data — IMPROVED with explicit KWW tails\n")
f.write("# Format: timestamp_us (relative) detector_channel\n")
f.write(f"# Generated: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n")
f.write(f"# Contains: 1.20134 mHz Quantum Heartbeat + KWW relaxation (τ={TAU_KWW} s, β={BETA_KWW})\n")
f.write("# Mirror steps every 833.3 s with 4.5 % initial overshoot decaying via KWW\n")
f.write("# Use with analysis scripts to reproduce 14.28σ-style PSD peak and KWW fits\n\n")
for ts, ch in zip(timestamps, channels):
f.write(f"{ts} {ch}\n")
print(f"✅ Synthetic data saved to: {filename}")
print(f" File size: {os.path.getsize(filename)/1024:.1f} KB")
# ====================== MAIN ======================
if __name__ == "__main__":
timestamps, channels = generate_synthetic_events()
save_synthetic_data(timestamps, channels)
print("\n🎉 Next steps:")
print("1. Run the generator: python scripts/generate_synthetic_event_data.py")
print("2. (Optional) Create scripts/analyze_synthetic.py to compute PSD + KWW fit")
print("3. Upload synthetic_event_sample.dat to GitHub data/processed/ and Zenodo")
print("4. The file now faithfully reproduces your KWW tails for quick verification!")




Comments