Created
August 24, 2017 20:16
-
-
Save baggepinnen/9dea6329d7c179f0bcd0a72c4e2c2a42 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function testsleep() | |
sleeptimes = logspace(-3,1,50) | |
actual_sleeptimes = map(sleeptimes) do st | |
@elapsed sleep(st) | |
end | |
sleeptimes, actual_sleeptimes | |
end | |
sleeptimes, actual_sleeptimes = testsleep() | |
diff = actual_sleeptimes-sleeptimes | |
plot(sleeptimes, [diff diff./sleeptimes], xlabel="Sleeptimes", ylabel=["Absolute difference" "Relative difference"], | |
xscale=:log10, yscale=[:linear :log10], ylims=[(0,1e-2) :auto], layout=2, legend=false) | |
A = log.(sleeptimes).^(0:4)' | |
x = A\log.(actual_sleeptimes) | |
e = log.(actual_sleeptimes) - A*x | |
predicted_time(t) = exp((log(t).^(0:4)')*x) | |
predicted_difference(t) = predicted_time(t)-t | |
plot(sleeptimes, [actual_sleeptimes predicted_time.(sleeptimes)], lab=["Actual", "Predicted"], xlabel="Sleeptime", yscale=:log10, xscale=:log10) | |
plot(sleeptimes, [abs.(diff-predicted_difference.(sleeptimes)) abs.(diff-predicted_difference.(sleeptimes))./sleeptimes], | |
xlabel="Sleeptimes", ylabel=["Absolute prediction error" "Relative prediction error"], | |
xscale=:log10, yscale=[:identity :log10], ylims=[(0,1e-2) :auto], | |
layout=2, legend=false) | |
# Estimated parameters stat. significant? | |
σ² = var(e) | |
Σ = σ²*inv(A'A) | |
p05 = abs.(x)./sqrt.(diag(Σ)) .> 1.96 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment