Skip to content

Commit

Permalink
Merge branch 'julia1.10update' of https://github.com/QuantEcon/lectur…
Browse files Browse the repository at this point in the history
…e-julia.myst into julia1.10update
  • Loading branch information
jlperla committed Jan 3, 2024
2 parents 3082b88 + 36e3f70 commit 669f7b6
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
_build
us_cities.txt
.vscode
.DS_Store
.vscode
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
8 changes: 4 additions & 4 deletions lectures/dynamic_programming/wald_friedman.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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),
Expand All @@ -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
Expand Down Expand Up @@ -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?
Expand Down
8 changes: 4 additions & 4 deletions lectures/dynamic_programming_squared/amss.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lectures/tools_and_techniques/numerical_linear_algebra.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 669f7b6

Please sign in to comment.