|
|
|
@ -57,6 +57,8 @@ for i, row in dff.iterrows():
|
|
|
|
|
|
|
|
|
|
dff.loc[i, 'loc'] = loc
|
|
|
|
|
dff.loc[i, 'scale'] = scale
|
|
|
|
|
dff.loc[i, 'min'] = x_min
|
|
|
|
|
dff.loc[i, 'max'] = x_max
|
|
|
|
|
|
|
|
|
|
if not PLOT:
|
|
|
|
|
continue
|
|
|
|
@ -87,7 +89,8 @@ for i, row in dff.iterrows():
|
|
|
|
|
plt.show()
|
|
|
|
|
|
|
|
|
|
# Save distribution parameters
|
|
|
|
|
dff[['loc', 'scale']].to_csv('cauchy-values.csv', float_format='%g')
|
|
|
|
|
dff[['loc', 'scale', 'min', 'max']].to_csv('cauchy-values.csv',
|
|
|
|
|
float_format='%g')
|
|
|
|
|
|
|
|
|
|
if PLOT:
|
|
|
|
|
# Plot all distributions
|
|
|
|
@ -100,9 +103,7 @@ if PLOT:
|
|
|
|
|
for i, row in dff.iterrows():
|
|
|
|
|
j += 1
|
|
|
|
|
|
|
|
|
|
x_min = row[5] + (row[5] - row[50])
|
|
|
|
|
x_max = row[95] + (row[95] - row[50])
|
|
|
|
|
x = np.linspace(x_min, x_max, num=1000)
|
|
|
|
|
x = np.linspace(row['min'], row['max'], num=1000)
|
|
|
|
|
|
|
|
|
|
y = stats.cauchy(loc=row['loc'], scale=row['scale']).pdf(x)
|
|
|
|
|
ax.plot(x, y * row['scale'], c=c[j])
|
|
|
|
@ -131,26 +132,24 @@ if PLOT:
|
|
|
|
|
r = stats.cauchy(loc=row['loc'], scale=row['scale']).rvs(1000000)
|
|
|
|
|
|
|
|
|
|
# Clip to our range
|
|
|
|
|
x_min = row[5] + (row[5] - row[50])
|
|
|
|
|
x_max = row[95] + (row[95] - row[50])
|
|
|
|
|
rc = np.clip(r, a_min=x_min, a_max=x_max)
|
|
|
|
|
rc = np.clip(r, a_min=row['min'], a_max=row['max'])
|
|
|
|
|
f = (r != rc).sum() / len(r) # Fraction outside range
|
|
|
|
|
|
|
|
|
|
ax.hist(rc, 100)
|
|
|
|
|
|
|
|
|
|
ym = ax.get_ylim()[1] # Maximum y value
|
|
|
|
|
|
|
|
|
|
ax.axvline(x=x_min, c='C3')
|
|
|
|
|
ax.axvline(x=row['min'], c='C3')
|
|
|
|
|
ax.axvline(x=row[5], c='C3')
|
|
|
|
|
ax.axvline(x=row[50], c='C3')
|
|
|
|
|
ax.axvline(x=row[95], c='C3')
|
|
|
|
|
ax.axvline(x=x_max, c='C3')
|
|
|
|
|
ax.axvline(x=row['max'], c='C3')
|
|
|
|
|
|
|
|
|
|
ax.annotate(' P0', (x_min, ym))
|
|
|
|
|
ax.annotate(' P_min', (row['min'], ym))
|
|
|
|
|
ax.annotate(' P5', (row[5], ym))
|
|
|
|
|
ax.annotate(' P50', (row[50], ym))
|
|
|
|
|
ax.annotate(' P95', (row[95], ym))
|
|
|
|
|
ax.annotate(' P100', (x_max, ym))
|
|
|
|
|
ax.annotate(' P_max', (row['max'], ym))
|
|
|
|
|
|
|
|
|
|
ax.annotate(f' Samples clipped = {100 * f:0.1f}%', (x_max, ym / 2))
|
|
|
|
|
|
|
|
|
|