From d21869598dad7606f178153c5c49445346a0625d Mon Sep 17 00:00:00 2001 From: William Chen Date: Mon, 4 Jan 2021 17:28:11 -0500 Subject: [PATCH 1/3] Add stable docs badge. --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d3ca63f..76e4736 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ # ModelConstructors.jl ![Build Status](https://github.com/FRBNY-DSGE/ModelConstructors.jl/workflows/build/badge.svg?branch=main) -[![](https://img.shields.io/badge/docs-latest-blue.svg)](https://frbny-dsge.github.io/ModelConstructors.jl/latest) +[![](https://img.shields.io/badge/docs-stable-blue.svg)](https://frbny-dsge.github.io/ModelConstructors.jl/stable) +[![](https://img.shields.io/badge/docs-dev-blue.svg)](https://frbny-dsge.github.io/ModelConstructors.jl/latest) [![codecov](https://codecov.io/gh/FRBNY-DSGE/ModelConstructors.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/FRBNY-DSGE/ModelConstructors.jl) This package contains the building blocks of model objects, such as `Parameter`, `Observable`, `Setting`, and `State` types. You may define any custom model, so long as it has parameters. The model object is used in both [DSGE.jl](https://github.com/FRBNY-DSGE/DSGE.jl) and [SMC.jl](https://github.com/FRBNY-DSGE/SMC.jl). From eb7ebd6b49b5d113e0a11550e41ac7d7404d33ab Mon Sep 17 00:00:00 2001 From: Aidan Gleich Date: Mon, 9 Aug 2021 11:11:01 -0400 Subject: [PATCH 2/3] Fix rand function for DegenerateMvNormal distributions --- src/distributions_ext.jl | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/distributions_ext.jl b/src/distributions_ext.jl index dd75235..d685cea 100644 --- a/src/distributions_ext.jl +++ b/src/distributions_ext.jl @@ -178,7 +178,27 @@ Distributions.rand(d::DegenerateMvNormal; cc::T = 1.0) where T<:AbstractFloat Generate a draw from `d` with variance optionally scaled by `cc^2`. """ function Distributions.rand(d::DegenerateMvNormal; cc::T = 1.0) where T<:AbstractFloat - return d.μ + cc*d.σ*randn(length(d)) + # abusing notation slightly, if Y is a degen MV normal r.v. with covariance matrix Σ, + # and Σ = U Λ^2 Vt according to the svd, then given an standard MV normal r.v X with + # the same dimension as Y, Y = μ + UΛX. + + # we need to ensure symmetry when computing SVD + U, λ_vals, Vt = svd((d.σ + d.σ')./2) + + # set near-zero values to zero + λ_vals[λ_vals .< 10^(-6)] .= 0 + + # leave x as 0 where λ_vals equals 0 (b/c r.v. is fixed where λ_vals = 0) + λ_vals = abs.(λ_vals) + x = zeros(length(λ_vals)) + for i in 1:length(λ_vals) + if λ_vals[i] == 0 + x[i] = 0 + else + x[i] = randn() + end + end + return d.μ + cc*U*diagm(sqrt.(λ_vals))*x end """ From ef2c9385f2f307ea71dfd222e090be152283acd6 Mon Sep 17 00:00:00 2001 From: CompatHelper Julia Date: Wed, 18 Aug 2021 00:44:15 +0000 Subject: [PATCH 3/3] CompatHelper: bump compat for Distributions to 0.25, (keep existing compat) --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 9c68888..1134c9d 100644 --- a/Project.toml +++ b/Project.toml @@ -20,7 +20,7 @@ UnPack = "3a884ed6-31ef-47d7-9d2a-63182c4928ed" [compat] DataFrames = "0.11.7, 0.12.0, 0.13, 0.14, 0.15, 0.16.0, 0.17, 0.18, 0.19, 0.20, 0.21, 0.22" -Distributions = "0.16, 0.17, 0.18, 0.19, 0.20, 0.21, 0.22, 0.23, 0.24" +Distributions = "0.16, 0.17, 0.18, 0.19, 0.20, 0.21, 0.22, 0.23, 0.24, 0.25" ForwardDiff = "^0.10" Nullables = "^0.0.8, 1" OrderedCollections = "^1.1.0"