From c7ff270f17724151ff9d895a055c3dae6d406bdf Mon Sep 17 00:00:00 2001 From: Dahua Lin Date: Sun, 2 Aug 2015 16:27:05 +0800 Subject: [PATCH] a minor bug fix to Chi --- src/univariate/continuous/chi.jl | 2 +- test/dirichlet.jl | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/univariate/continuous/chi.jl b/src/univariate/continuous/chi.jl index d0e319af2..9b98e8aa6 100644 --- a/src/univariate/continuous/chi.jl +++ b/src/univariate/continuous/chi.jl @@ -53,7 +53,7 @@ logpdf(d::Chi, x::Float64) = (ν = d.ν; (1.0 - 0.5 * ν) * logtwo + (ν - 1.0) * log(x) - 0.5 * x^2 - lgamma(0.5 * ν) ) -gradlogpdf(d::Chi, x::Float64) = x >= 0.0 ? (d.μ - 1.0) / x - x : 0.0 +gradlogpdf(d::Chi, x::Float64) = x >= 0.0 ? (d.ν - 1.0) / x - x : 0.0 cdf(d::Chi, x::Float64) = chisqcdf(d.ν, x^2) ccdf(d::Chi, x::Float64) = chisqccdf(d.ν, x^2) diff --git a/test/dirichlet.jl b/test/dirichlet.jl index 29ea24cc5..904358a08 100644 --- a/test/dirichlet.jl +++ b/test/dirichlet.jl @@ -3,6 +3,8 @@ using Distributions using Base.Test +srand(34567) + d = Dirichlet(3, 2.0) @test length(d) == 3 @@ -73,4 +75,3 @@ r = fit_mle(Dirichlet, x) r = fit_mle(Dirichlet, x, fill(2.0, n)) @test_approx_eq_eps r.alpha d.alpha 0.25 -