From 6b7363099b9c8a9bf2f7f2935f4d3e3ebb74e0d8 Mon Sep 17 00:00:00 2001 From: Augustin Yiptong Date: Mon, 31 Aug 2015 13:09:58 -0700 Subject: [PATCH] Change r parameter from Int to Float64 --- src/univariate/discrete/negativebinomial.jl | 2 +- test/discrete_test.json | 53 +++++++++++++++++++++ test/discrete_test.lst | 1 + test/prepdref.py | 2 +- 4 files changed, 56 insertions(+), 2 deletions(-) diff --git a/src/univariate/discrete/negativebinomial.jl b/src/univariate/discrete/negativebinomial.jl index 4990662e41..554bfd6c64 100644 --- a/src/univariate/discrete/negativebinomial.jl +++ b/src/univariate/discrete/negativebinomial.jl @@ -5,7 +5,7 @@ # discrete survival times. immutable NegativeBinomial <: DiscreteUnivariateDistribution - r::Int + r::Float64 p::Float64 function NegativeBinomial(r::Real, p::Real) diff --git a/test/discrete_test.json b/test/discrete_test.json index 9f1d9447e1..324111507a 100644 --- a/test/discrete_test.json +++ b/test/discrete_test.json @@ -1328,6 +1328,59 @@ "var": 5.5555555555555571 } ], + [ + "NegativeBinomial(0.5, 0.5)", + { + "dtype": "NegativeBinomial", + "entropy": 0.94337075926933467, + "maximum": "inf", + "mean": 0.5, + "median": 0.0, + "minimum": 0, + "params": { + "failprob": 0.5, + "succprob": 0.5 + }, + "points": [ + { + "cdf": 0.70710678118654768, + "logpdf": -0.34657359027997264, + "x": 0 + }, + { + "cdf": 0.88388347648318444, + "logpdf": -1.732867951399863, + "x": 1 + }, + { + "cdf": 0.95017473721942325, + "logpdf": -2.7136972044115892, + "x": 2 + }, + { + "cdf": 0.97779609585952276, + "logpdf": -3.5891659417654891, + "x": 3 + }, + { + "cdf": 0.98988044026456623, + "logpdf": -4.4158445149499572, + "x": 4 + }, + { + "cdf": 0.99531839524683585, + "logpdf": -5.2143522111677285, + "x": 5 + } + ], + "q10": 0.0, + "q25": 0.0, + "q50": 0.0, + "q75": 1.0, + "q90": 2.0, + "var": 1.0 + } + ], [ "Poisson()", { diff --git a/test/discrete_test.lst b/test/discrete_test.lst index b207d4789e..c6f50a9e39 100644 --- a/test/discrete_test.lst +++ b/test/discrete_test.lst @@ -34,6 +34,7 @@ NegativeBinomial() NegativeBinomial(6) NegativeBinomial(1, 0.5) NegativeBinomial(5, 0.6) +NegativeBinomial(0.5, 0.5) Poisson() Poisson(0.0) diff --git a/test/prepdref.py b/test/prepdref.py index 7eecc78089..b4b7a3dc70 100644 --- a/test/prepdref.py +++ b/test/prepdref.py @@ -239,7 +239,7 @@ def get_dinfo(dname, args): elif dname == "NegativeBinomial": assert len(args) <= 2 - r = int(get(args, 0) or 1) + r = get(args, 0) or 1 p = get(args, 1) or 0.5 return (nbinom(r, p), (0, inf), {"succprob" : p, "failprob" : 1.0 - p})