Completed Exercise 2
This commit is contained in:
parent
02e81cf7bb
commit
fdacfc4b09
17 changed files with 381 additions and 10 deletions
70
Exercise 2/times.py
Normal file
70
Exercise 2/times.py
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
|
||||
resolutions = [10,20,40,80,100,160,200,320]
|
||||
resolutions2 = []
|
||||
for resolution in resolutions:
|
||||
resolutions2.append(resolution**2)
|
||||
|
||||
numericTimes = [0.515,2.018,7.828,30.030,46.033,116.879,177.527,464.059]
|
||||
monte10 = [0.012,0.024,0.084,0.314,0.0483,1.205,1.862,4.710]
|
||||
monte50 = [0.021,0.063,0.250,1.007,1.578,3.915,6.267,15.407]
|
||||
monte200 = [0.063,0.232,0.932,3.697,5.506,14.197,22.452,56.731]
|
||||
monte800 = [0.231,0.904,3.559,14.420,22.403,56.611,88.400,227.990]
|
||||
monte1600 = [0.466,1.808,7.245,28.605,44.723,114.017,179.114,455.755]
|
||||
monte2400 = [0.696,2.762,10.894,42.909,66.179,177.273,274.045,693.686]
|
||||
|
||||
m, b = np.polyfit(resolutions2, numericTimes, 1)
|
||||
numericTimesFit = []
|
||||
for resolution in resolutions2:
|
||||
numericTimesFit.append(resolution*m)
|
||||
|
||||
m, b = np.polyfit(resolutions2, monte10, 1)
|
||||
monte10Fit = []
|
||||
for resolution in resolutions2:
|
||||
monte10Fit.append(resolution*m)
|
||||
|
||||
m, b = np.polyfit(resolutions2, monte50, 1)
|
||||
monte50Fit = []
|
||||
for resolution in resolutions2:
|
||||
monte50Fit.append(resolution*m)
|
||||
|
||||
m, b = np.polyfit(resolutions2, monte200, 1)
|
||||
monte200Fit = []
|
||||
for resolution in resolutions2:
|
||||
monte200Fit.append(resolution*m)
|
||||
|
||||
m, b = np.polyfit(resolutions2, monte800, 1)
|
||||
monte800Fit = []
|
||||
for resolution in resolutions2:
|
||||
monte800Fit.append(resolution*m)
|
||||
|
||||
m, b = np.polyfit(resolutions2, monte1600, 1)
|
||||
monte1600Fit = []
|
||||
for resolution in resolutions2:
|
||||
monte1600Fit.append(resolution*m)
|
||||
|
||||
m, b = np.polyfit(resolutions2, monte2400, 1)
|
||||
monte2400Fit = []
|
||||
for resolution in resolutions2:
|
||||
monte2400Fit.append(resolution*m)
|
||||
|
||||
ax = plt.axes()
|
||||
plt.scatter(resolutions2, numericTimes, color="red")
|
||||
plt.plot(resolutions2, numericTimesFit, color="red", label="Numeric method")
|
||||
plt.scatter(resolutions2, monte10, color="orange")
|
||||
plt.plot(resolutions2, monte10Fit, color="orange", label="Monte method with 10 samples")
|
||||
plt.scatter(resolutions2, monte50, color="yellow")
|
||||
plt.plot(resolutions2, monte50Fit, color="yellow", label="Monte method with 50 samples")
|
||||
plt.scatter(resolutions2, monte200, color="green")
|
||||
plt.plot(resolutions2, monte200Fit, color="green", label="Monte method with 200 samples")
|
||||
plt.scatter(resolutions2, monte800, color="blue")
|
||||
plt.plot(resolutions2, monte800Fit, color="blue", label="Monte method with 800 samples")
|
||||
plt.scatter(resolutions2, monte1600, color="purple")
|
||||
plt.plot(resolutions2, monte1600Fit, color="purple", label="Monte method with 1600 samples")
|
||||
plt.scatter(resolutions2, monte2400, color="pink")
|
||||
plt.plot(resolutions2, monte2400Fit, color="pink", label="Monte method with 2400 samples")
|
||||
plt.xlabel("Resolution^2 (Pixels^2)")
|
||||
plt.ylabel("Time (s)")
|
||||
plt.legend()
|
||||
plt.show()
|
||||
Loading…
Add table
Add a link
Reference in a new issue