From 50ca87fcc147f700382b669cf623a02485acdf37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= <stepan@dynare.org> Date: Sat, 19 Oct 2019 18:51:31 +0200 Subject: [PATCH] Added normcdf function in Utils module. Cannot use normcdf from StatsFuns because the ordering of the inputs are different. --- REQUIRE | 3 ++- src/Utils.jl | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/REQUIRE b/REQUIRE index d4e0ff3..22417eb 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,5 +1,6 @@ -julia 0.6- +julia 1.0- Calculus NLsolve Suppressor BinaryProvider +SpecialFunctions \ No newline at end of file diff --git a/src/Utils.jl b/src/Utils.jl index 6fd7eff..d2c9e6f 100644 --- a/src/Utils.jl +++ b/src/Utils.jl @@ -1,6 +1,6 @@ module Utils ## - # Copyright (C) 2015 Dynare Team + # Copyright © 2015-2019 Dynare Team # # This file is part of Dynare. # @@ -18,6 +18,10 @@ module Utils # along with Dynare. If not, see <http://www.gnu.org/licenses/>. ## +import Base: @irrational +@irrational sqrt2 1.4142135623730950488 sqrt(big(2.0)) +@irrational invsqrt2 0.7071067811865475244 inv(big(sqrt2)) + export get_power_deriv function get_power_deriv(x::Float64, p::Real, k::Int) @@ -33,4 +37,16 @@ function get_power_deriv(x::Float64, p::Real, k::Int) return dxp end + +using SpecialFunctions + +export normcdf + +normcdf(z::Number) = erfc(-z * invsqrt2)/2 + +function normcdf(x::Number, μ::Real, σ::Real) + z = (x - μ) / σ + normcdf(z) +end + end -- GitLab