Coverage for src/causalspyne/implicit_spectrum_histogram.py: 0%
15 statements
« prev ^ index » next coverage.py v7.11.0, created at 2026-05-15 16:30 +0000
« prev ^ index » next coverage.py v7.11.0, created at 2026-05-15 16:30 +0000
1import numpy as np
2import matplotlib.pyplot as plt
3from scipy import stats
4from causalspyne.implicit_gen_Sigma import gen_spectrum
7# Generate sample data
9# samples = np.random.normal(size=10000)
10samples = [gen_spectrum() for _ in range(10000)]
11# Create histogram
12fig, ax = plt.subplots(figsize=(8, 6))
14hist, bins, _ = ax.hist(samples, bins=30, density=True, alpha=0.7,
15 label="Histogram")
17# Calculate bin centers for PDF plotting
18bin_centers = 0.5 * (bins[1:] + bins[:-1])
20# Compute PDF
21pdf = stats.norm.pdf(bin_centers)
23# Plot PDF
24ax.plot(bin_centers, pdf, 'r-', label="PDF")
26# Customize plot
27ax.set_xlabel('eigenvalue')
28ax.set_ylabel('Density')
29ax.set_title('Histogram of maximum eigenvalue distribution')
30ax.legend()
32plt.show()