ix
This commit is contained in:
@@ -10,11 +10,11 @@ def read_file(file: str) -> np.typing.ArrayLike:
|
|||||||
|
|
||||||
all_data = {
|
all_data = {
|
||||||
'200': read_file('200'),
|
'200': read_file('200'),
|
||||||
'100': read_file('100-1') + read_file('100-2'),
|
'100': np.hstack([read_file('100-1'), read_file('100-2')]),
|
||||||
'40': sum([read_file(f'40-{i}') for i in range(1, 6)])
|
'40': np.hstack([read_file(f'40-{i}') for i in range(1, 6)])
|
||||||
}
|
}
|
||||||
|
|
||||||
fig, axs = plt.subplots(len(all_data), 1, sharex='col')
|
fig, axs = plt.subplots(len(all_data), 1)
|
||||||
i = 0
|
i = 0
|
||||||
|
|
||||||
for dwell_time in all_data:
|
for dwell_time in all_data:
|
||||||
@@ -42,48 +42,54 @@ for dwell_time in all_data:
|
|||||||
times_dev_more_than_P = (np.abs(data - mean) > P).sum()
|
times_dev_more_than_P = (np.abs(data - mean) > P).sum()
|
||||||
print(f'Found {times_dev_more_than_P} / {N} ({times_dev_more_than_P / N * 100:0.2f}%) samples deviating from the mean more than P {P:0.2f}')
|
print(f'Found {times_dev_more_than_P} / {N} ({times_dev_more_than_P / N * 100:0.2f}%) samples deviating from the mean more than P {P:0.2f}')
|
||||||
|
|
||||||
ax = axs[i]
|
if True:
|
||||||
ax.set_xlabel('Run Count')
|
ax = axs[i]
|
||||||
ax.set_ylabel('Events Measured')
|
ax.set_xlabel('Run Count')
|
||||||
ax.set_title('Raw Data')
|
ax.set_ylabel('Events Measured')
|
||||||
ax.scatter(np.arange(1, len(data)+1), data, s=4)
|
ax.set_title(f'Raw Data ({dwell_time} ms)')
|
||||||
ax.legend(['\n'.join([
|
ax.scatter(np.arange(1, len(data)+1), data, s=4)
|
||||||
f'Mean: {mean:0.2f}',
|
ax.legend(['\n'.join([
|
||||||
f'Sample Sd. Dev: {stdev:0.2f}',
|
f'Mean: {mean:0.2f}',
|
||||||
f'P: {P:0.2f}',
|
f'Sample Sd. Dev: {stdev:0.2f}',
|
||||||
f'Events > sigma: {times_dev_more_than_s} ({times_dev_more_than_s / N * 100:0.2f}%)',
|
f'Sqrt(Mean): {sigma:0.2f}',
|
||||||
f'Events > P: {times_dev_more_than_P} ({times_dev_more_than_P / N * 100:0.2f}%)'
|
f'P: {P:0.2f}',
|
||||||
])])
|
f'Events > sigma: {times_dev_more_than_s} ({times_dev_more_than_s / N * 100:0.2f}%)',
|
||||||
|
f'Events > P: {times_dev_more_than_P} ({times_dev_more_than_P / N * 100:0.2f}%)'
|
||||||
|
])])
|
||||||
|
|
||||||
# ax = axs[i][1]
|
if False:
|
||||||
# ax.set_visible(False)
|
ax = axs[i]
|
||||||
|
|
||||||
# ax.set_title(f'Cumulative Average ({dwell_time}ms Dwell time)')
|
ax.set_title(f'Cumulative Average ({dwell_time}ms Dwell time)')
|
||||||
# ax.set_xlabel('After N Runs')
|
ax.set_xlabel('After N Runs')
|
||||||
# ax.set_ylabel('Cumulative Average')
|
ax.set_ylabel('Cumulative Average')
|
||||||
|
|
||||||
# sample_num = np.arange(1, N + 1)
|
sample_num = np.arange(1, N + 1)
|
||||||
# cumulative_average = np.cumsum(data) / sample_num
|
cumulative_average = np.cumsum(data) / sample_num
|
||||||
# ax.plot(sample_num, cumulative_average, label=f'Final Value: {cumulative_average[-1]:0.2f}')
|
error = 1 / np.sqrt(sample_num) # Not used, tiny
|
||||||
# ax.legend()
|
ax.plot(sample_num, cumulative_average, label=f'Final Value: {cumulative_average[-1]:0.2f}')
|
||||||
|
ax.legend()
|
||||||
|
|
||||||
|
if False:
|
||||||
|
ax = axs[i]
|
||||||
|
N, bins, patches = ax.hist(data, density=True, bins=16, label='Measured Data')
|
||||||
|
|
||||||
# ax = axs[i]
|
fracs = N / N.max()
|
||||||
# N, bins, patches = ax.hist(data, density=True, bins=32, label='Measured Data')
|
norm = colors.Normalize(fracs.min(), fracs.max())
|
||||||
|
for thisfrac, thispatch in zip(fracs, patches):
|
||||||
|
color = plt.cm.viridis(norm(thisfrac))
|
||||||
|
thispatch.set_facecolor(color)
|
||||||
|
|
||||||
# fracs = N / N.max()
|
ax.set_xlabel('Event Count')
|
||||||
# norm = colors.Normalize(fracs.min(), fracs.max())
|
ax.set_ylabel('Frequency')
|
||||||
# for thisfrac, thispatch in zip(fracs, patches):
|
|
||||||
# color = plt.cm.viridis(norm(thisfrac))
|
|
||||||
# thispatch.set_facecolor(color)
|
|
||||||
|
|
||||||
# ax.set_xlabel('Event Count')
|
linspace = np.arange(bins.min(), bins.max())
|
||||||
# ax.set_ylabel('Frequency')
|
gaussian = scipy.stats.norm.pdf(linspace, mean, stdev)
|
||||||
|
ax.set_title(f'Distribution ({dwell_time}ms Dwell time)')
|
||||||
# linspace = np.arange(bins.min(), bins.max())
|
ax.plot(linspace, gaussian, label='Fitted Gaussian')
|
||||||
# gaussian = scipy.stats.norm.pdf(linspace, mean, stdev)
|
ax.legend()
|
||||||
# ax.plot(linspace, gaussian, label='Fitted Gaussian')
|
|
||||||
# ax.legend()
|
|
||||||
|
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
|
fig.tight_layout()
|
||||||
plt.show()
|
plt.show()
|
||||||
Reference in New Issue
Block a user