-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_rho_dist.py
More file actions
40 lines (30 loc) · 1.3 KB
/
plot_rho_dist.py
File metadata and controls
40 lines (30 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import numpy as np #type: ignore
import matplotlib.pyplot as plt #type: ignore
import pandas as pd #type: ignore
# Load the CSV data
data = pd.read_csv('results.csv')
# Extract the 'Rho' column from the CSV
rho_values = data['Rho'].values
# Calculate the distribution of Rho values
rho_range = np.arange(1, 33) # Rho values range from 1 to 32
rho_distribution = np.array([np.sum(rho_values == i) for i in rho_range])
# Normalize the distribution to get probabilities
total_values = len(rho_values)
rho_probabilities = rho_distribution / total_values
# Theoretical distribution Pr[ρ(y) = i] = 2^(-i)
theoretical_distribution = np.array([2.0**-i for i in rho_range])
# Plotting the empirical distribution and the theoretical distribution
plt.figure(figsize=(10, 6))
# Plot empirical distribution
plt.bar(rho_range, rho_probabilities, color='blue', alpha=0.6, label='Empirical Distribution')
# Plot theoretical distribution
plt.plot(rho_range, theoretical_distribution, color='red', marker='o', linestyle='-', label='Theoretical Distribution')
# Labels and title
plt.xlabel('Rho Value')
plt.ylabel('Probability (linear scale)')
#plt.yscale('log')
plt.title('Empirical vs Theoretical Distribution of Rho Values')
plt.legend()
# Show the plot
# plt.show()
plt.savefig('rho_distribution_plot_ylin.jpg', format='jpg', dpi=300)