Skip to content

Commit

Permalink
Merge pull request JuliaStats#411 from augustinyiptong/master
Browse files Browse the repository at this point in the history
Change r parameter from Int to Float64
  • Loading branch information
andreasnoack committed Sep 1, 2015
2 parents 94d6c49 + 6b73630 commit b140bf0
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/univariate/discrete/negativebinomial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# discrete survival times.

immutable NegativeBinomial <: DiscreteUnivariateDistribution
r::Int
r::Float64
p::Float64

function NegativeBinomial(r::Real, p::Real)
Expand Down
53 changes: 53 additions & 0 deletions test/discrete_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -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()",
{
Expand Down
1 change: 1 addition & 0 deletions test/discrete_test.lst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ NegativeBinomial()
NegativeBinomial(6)
NegativeBinomial(1, 0.5)
NegativeBinomial(5, 0.6)
NegativeBinomial(0.5, 0.5)

Poisson()
Poisson(0.0)
Expand Down
2 changes: 1 addition & 1 deletion test/prepdref.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down

0 comments on commit b140bf0

Please sign in to comment.