Skip to content

Instantly share code, notes, and snippets.

Patrick Kofod Mogensen pkofod

View GitHub Profile
View gist:b3b35aef3810cca6ac9c7d8c33bfc59e
julia> @code_warntype Pumas.vpc(pkres.model, pkres.data, coef(pkres), 1)
Variables
#self#::Core.Compiler.Const(Pumas.vpc, false)
m::PumasModel{ParamSet{NamedTuple{(:tvcl, :tvv, :pmoncl, :Ω, :σ_prop),Tuple{RealDomain{Int64,TransformVariables.Infinity{true},Float64},RealDomain{Int64,TransformVariables.Infinity{true},Float64},RealDomain{Float64,TransformVariables.Infinity{true},Float64},PDiagDomain{PDMats.PDiagMat{Float64,Array{Float64,1}}},RealDomain{Int64,TransformVariables.Infinity{true},Float64}}}},var"#3#12",var"#4#13",var"#5#15",Central1,var"#6#16",var"#9#19"}
population::Array{Subject{NamedTuple{(:dv,),Tuple{Array{Union{Missing, Float64},1}}},NamedTuple{(:isPM, :wt),Tuple{Int64,Int64}},Array{Pumas.Event{Float64,Float64,Float64,Float64,Float64,Float64,Int64},1},Array{Float64,1},Pumas.ConstantCovar{NamedTuple{(:isPM, :wt),Tuple{Int64,Int64}}},Float64},1}
param::NamedTuple{(:tvcl, :tvv, :pmoncl, :Ω, :σ_prop),Tuple{Float64,Float64,Float64,PDMats.PDiagMat{Float64,Array{Float64,1}},Float64}}
reps::Int
View gist:5e39d37a1d764bc2f8bc6648e6cdbb91
This file has been truncated, but you can view the full file.
julia> o_ode = fit(iv_ode,data,param,Pumas.FOCEI())
View gist:69bb5fee1bbad09cb93c3799a69c3863
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])
View julien
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
View gist:3083c68ee2a1ebce2c1302e7e8118e39
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
View fminbox_nogradient.jl
_
_ _ _(_)_ | 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
View gist:ce449cc8561880739954221a656fdecb
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)
View ldexp_exp
# 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 <das@FreeBSD.ORG>
# 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
View gist:bf3efe415825b8c660e0f484a6185641
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
View anitamette.jl
β = 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)
You can’t perform that action at this time.