Page MenuHomec4science

dopri5-p.py
No OneTemporary

File Metadata

Created
Tue, Dec 3, 03:22

dopri5-p.py

#!/usr/bin/python
import matplotlib
import numpy as np
import matplotlib.pyplot as plt
p = [ 80,
70,
60,
50,
40,
30,
20 ]
eig = [ 160,
150,
138,
125,
110,
94,
75 ]
p = np.array(p)
eig = np.array(eig)
fit = np.polyfit(np.log(p), np.log(eig), 1)
fig, axis = plt.subplots()
axis.set_title("DOPRI5 estim")
axis.set_xlabel("p")
axis.set_ylabel("lambda")
axis.loglog(p, eig, 'r*', label='data')
axis.loglog(p, np.exp(fit[0] * np.log(p) + fit[1]), 'k-', label='fit')
axis.legend()
plt.show()
print("Fit: %g * p^%g" % (np.exp(fit[1]), fit[0]))

Event Timeline