-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutils.py
More file actions
23 lines (17 loc) · 896 Bytes
/
utils.py
File metadata and controls
23 lines (17 loc) · 896 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import numpy as np
import matplotlib.pyplot as plt
import torch
def show_cdf(data, percentile_threshold=95):
sorted_data = np.sort(data)
cdf_values = np.arange(1, len(sorted_data) + 1) / len(sorted_data)
threshold_value = np.percentile(data, percentile_threshold)
plt.plot(sorted_data, cdf_values, marker='.', linestyle='none', color='skyblue')
plt.xlabel('Value')
plt.xscale('log')
plt.ylabel('Cumulative Probability')
plt.title(f'Cumulative Distribution Function (Threshold at {percentile_threshold}%: {threshold_value:.2f})')
plt.axhline(y=percentile_threshold / 100, color='red', linestyle='dashed', linewidth=1, label=f'{percentile_threshold}% Threshold')
plt.axvline(x=threshold_value, color='red', linestyle='dashed', linewidth=1)
plt.legend()
print(f"Value at {percentile_threshold}% threshold: {threshold_value:.2f}")
plt.show()