diff --git a/.gitignore b/.gitignore index e00f5c0b..b23096d0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ _build -us_cities.txt \ No newline at end of file +us_cities.txt +.DS_Store +.vscode diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index fca9d402..00000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "julia.environmentPath": "c:\\Users\\jesse\\Documents\\GitHub\\lecture-julia.myst" -} \ No newline at end of file diff --git a/README.md b/README.md index 181a3519..bf018b82 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,6 @@ As a helper, you can call a shell script to do it for an entire folder bash format_all_directory.sh lectures/dynamic_programming ``` or to also do the unicode substitutions -```bash bash format_all_directory.sh lectures/dynamic_programming true ``` diff --git a/lectures/dynamic_programming/wald_friedman.md b/lectures/dynamic_programming/wald_friedman.md index 23f8f216..033f5382 100644 --- a/lectures/dynamic_programming/wald_friedman.md +++ b/lectures/dynamic_programming/wald_friedman.md @@ -509,7 +509,7 @@ function simulation(problem) return return_output ? (alpha, beta, outcomes, costs, trials) : nothing end -function Problem(d0 = Beta(1, 1), d1 = Beta(9, 9), +function Problem(;d0 = Beta(1, 1), d1 = Beta(9, 9), L0 = 2, L1 = 2, c = 0.2, p = 0.5, n = 100, return_output = false) @@ -524,7 +524,7 @@ tags: [remove-cell] @testset "Verifying Output" begin Random.seed!(0) (;d0, d1, L0, L1, c) = Problem() - alpha, beta, outcomes, costs, trials = simulation(Problem(return_output = true)) + alpha, beta, outcomes, costs, trials = simulation(Problem(;return_output = true)) #test alpha ≈ 0.57428237 #test beta ≈ 0.352510338 choices = first.(choice.((clamp(beta - eps(), 0, 1), @@ -551,7 +551,7 @@ tags: [remove-cell] @testset "Comparative Statics" begin Random.seed!(0) (;d0, d1, L0, L1, c) = Problem() - alpha, beta, outcomes, costs, trials = simulation(Problem(c = 2c, return_output = true)) + alpha, beta, outcomes, costs, trials = simulation(Problem(;c = 2c, return_output = true)) #test alpha ≈ 0.53551172 atol = 1e-3 #test beta ≈ 0.41244737 atol = 1e-3 #test mean(outcomes) ≈ 0.39 atol = 1e-2 @@ -582,7 +582,7 @@ Before you look, think about what will happen: ```{code-cell} julia Random.seed!(0); -simulation(Problem(c = 0.4)); +simulation(Problem(;c = 0.4)); ``` Notice what happens? diff --git a/lectures/dynamic_programming_squared/amss.md b/lectures/dynamic_programming_squared/amss.md index 9142b7d9..1bc4fee1 100644 --- a/lectures/dynamic_programming_squared/amss.md +++ b/lectures/dynamic_programming_squared/amss.md @@ -1036,14 +1036,14 @@ function solve_time1_bellman(model::Model{TR}, μgrid::AbstractArray) where {TR xprimes = repeat(x, 1, S) xgrid[s_, :] = x for sprime = 1:S - splc = CubicSpline(c[:, sprime][end:-1:1], x[end:-1:1]) - spln = CubicSpline(n[:, sprime][end:-1:1], x[end:-1:1]) - splx = CubicSpline(xprimes[:, sprime][end:-1:1], x[end:-1:1]) + splc = CubicSpline(c[:, sprime][end:-1:1], x[end:-1:1];extrapolate=true) + spln = CubicSpline(n[:, sprime][end:-1:1], x[end:-1:1];extrapolate=true) + splx = CubicSpline(xprimes[:, sprime][end:-1:1], x[end:-1:1];extrapolate=true) cf[s_, sprime] = y -> splc(y) nf[s_, sprime] = y -> spln(y) xprimef[s_, sprime] = y -> splx(y) end - splV = CubicSpline(V[end:-1:1], x[end:-1:1]) + splV = CubicSpline(V[end:-1:1], x[end:-1:1];extrapolate=true) Vf[s_] = y -> splV(y) end diff --git a/lectures/tools_and_techniques/numerical_linear_algebra.md b/lectures/tools_and_techniques/numerical_linear_algebra.md index d8996fb2..00143879 100644 --- a/lectures/tools_and_techniques/numerical_linear_algebra.md +++ b/lectures/tools_and_techniques/numerical_linear_algebra.md @@ -494,7 +494,7 @@ Af = qr(A) Q = Af.Q R = [Af.R; zeros(N - M, M)] # Stack with zeros @show Q * R ≈ A -x = R \ Q' * b # simplified QR solution for least squares +x = R \ Matrix(Q)' * b # simplified QR solution for least squares ``` This stacks the `R` with zeros, but the more specialized algorithm would not multiply directly