This file contains hidden or 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
--- Benchmarking 0.0 | |
BenchmarkTools.Trial: | |
memory estimate: 0 bytes | |
allocs estimate: 0 | |
-------------- | |
minimum time: 3.977 ns (0.00% GC) | |
median time: 4.582 ns (0.00% GC) | |
mean time: 4.687 ns (0.00% GC) | |
maximum time: 19.703 ns (0.00% GC) | |
-------------- |
This file contains hidden or 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
""" | |
frexp_exp(x) | |
Compute ``exp(x)``, scaled to avoid spurious overflow. An exponent is | |
returned separately in ``expt``. | |
# Examples | |
```jldoctest | |
julia> frexp_exp(1354.9) |
This file contains hidden or 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
β = 0.9995 | |
Wₕ = 100 | |
W̄ₕ = Wₕ/(1-β) | |
Wₗ = 50 | |
W̄ₗ = Wₗ/(1-β) | |
pₕ = 0.35 | |
pₗ = 0.65 | |
Bₖ = 0.6*Wₗ | |
U(x) = sqrt(x) | |
Uₕ = U(Bₖ-1) |
This file contains hidden or 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
julia> @profile res = optimize(fung, x0, LBFGS(), Optim.Options(show_trace=false,iterations=100_000,g_tol=1e-6,f_tol=1e-20)) | |
Profile.print()Results of Optimization Algorithm | |
* Algorithm: L-BFGS | |
* Starting Point: [0.5611813319535237,0.3528280830687891, ...] | |
* Minimizer: [0.063775434544103,0.49327292600719447, ...] | |
* Minimum: 3.682547e+03 | |
* Iterations: 11 | |
* Convergence: true | |
* |x - x'| ≤ 0.0e+00: false | |
|x - x'| = 1.18e-09 |
This file contains hidden or 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
# This code is a Julia translation of the C code from Openlibm (http://www.openlibm.org/) | |
# with the following license: | |
# Copyright (c) 2011 David Schultz <[email protected]> | |
# All rights reserved. | |
# | |
# Redistribution and use in source and binary forms, with or without | |
# modification, are permitted provided that the following conditions | |
# are met: | |
# 1. Redistributions of source code must retain the above copyright |
This file contains hidden or 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
I just spent half a day wondering why my Jacobians were wrong, and didn't even think to look at `I`'s role, but is this not super weird? | |
``` | |
julia> versioninfo() | |
Julia Version 0.6.4 | |
Commit 9d11f62bcb (2018-07-09 19:09 UTC) | |
Platform Info: | |
OS: Linux (x86_64-pc-linux-gnu) | |
CPU: AMD Ryzen 3 1200 Quad-Core Processor | |
WORD_SIZE: 64 | |
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Zen MAX_THREADS=16) |
This file contains hidden or 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
_ | |
_ _ _(_)_ | Documentation: https://docs.julialang.org | |
(_) | (_) (_) | | |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help. | |
| | | | | | |/ _` | | | |
| | |_| | | | (_| | | Version 1.0.2 (2018-11-08) | |
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release | |
|__/ | | |
julia> using Optim |
This file contains hidden or 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
0.000004 seconds (5 allocations: 144 bytes) | |
Body::Tuple{Float64,Float64,Bool} | |
1 ── %1 = (Base.getfield)(opt, :ratio)::Float64 | |
│ %2 = (Base.getfield)(opt, :c)::Float64 | |
│ %3 = (Base.getfield)(opt, :ls_max_iter)::Int64 | |
│ %4 = (Base.getfield)(d, :data)::Tuple{Float64,Float64} | |
│ %5 = (Base.getfield)(%4, 1, false)::Float64 | |
│ %6 = (Base.getfield)(∇f_x, :data)::Tuple{Float64,Float64} | |
│ %7 = (Base.getfield)(%6, 1, false)::Float64 | |
│ %8 = (Base.mul_float)(%5, %7)::Float64 |
This file contains hidden or 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
from HARK.ConsumptionSaving.ConsIndShockModel import IndShockConsumerType | |
import HARK.ConsumptionSaving.ConsumerParameters as param | |
import copy | |
init_lifecycle = copy.copy(param.init_idiosyncratic_shocks) | |
init_lifecycle['PermGroFac'] = [1.01, 1.00] | |
init_lifecycle['PermShkStd'] = [0.1, 0.0] | |
init_lifecycle['TranShkStd'] = [0.3,0.0] | |
init_lifecycle['LivPrb'] = [0.99,0.9] | |
init_lifecycle['T_cycle'] = 2 |
This file contains hidden or 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
using StaticArrays | |
using NLSolvers | |
using LinearAlgebra | |
function himmelblau(∇²f, ∇f, x) | |
if !(∇²f == nothing) | |
∇²f11 = 12.0 * x[1]^2 + 4.0 * x[2] - 42.0 | |
∇²f12 = 4.0 * x[1] + 4.0 * x[2] | |
∇²f21 = 4.0 * x[1] + 4.0 * x[2] | |
∇²f22 = 12.0 * x[2]^2 + 4.0 * x[1] - 26.0 | |
∇²f = @SMatrix([∇²f11 ∇²f12; ∇²f21 ∇²f22]) |