analistica/ex-5/plots/fit_plot.py
Giù Marcer 093faf3fe8 ex-5: implement the code for plotting σ_MC vs calls
move all the functions to lib.c and lib.h; add this two librearies to makefile;
make plot.py more easy to use for passing to one mode to the other (show or
save figure); create fit_plot and create the figure 5-fit.pdf.
2020-07-05 11:36:22 +02:00

32 lines
705 B
Python
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python
import matplotlib.pyplot as plt
import numpy as np
import sys
table = np.loadtxt(sys.stdin, unpack=True, skiprows=2, delimiter='|')
calls, I_MC, σ_MC, I_MI, σ_MI, I_VE, σ_VE, chi = table
exact = 1.7182818285
plt.figure()
# plt.figure(figsize=(5, 3))
# plt.rcParams['font.size'] = 8
plt.title('Integral uncertainty', loc='right')
plt.ylabel('$\sigma_I$')
plt.xlabel('calls')
plt.xscale('log')
plt.yscale('log')
plt.plot(calls, σ_MC, linestyle='', marker='o',
color='#92182b', label='$\sigma_I$')
x = np.logspace(1, 8, 5)
a = 0.48734
b = -0.49938
plt.plot(x, a*(x**b), color='gray')
plt.tight_layout()
# plt.savefig('notes/images/5-fit.pdf')
plt.show()