Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix sample-(neg-)binomial mangling arguments #124

Merged
merged 1 commit into from Feb 11, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 10 additions & 11 deletions modules/incanter-core/src/incanter/stats.clj
Expand Up @@ -959,7 +959,7 @@
:rate (default 1)

See also:
pdf-exp, and cdf-exp
pdf-exp and cdf-exp

References:
http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/Exponential.html
Expand Down Expand Up @@ -1162,7 +1162,7 @@
:prob (default 1/2)

See also:
cdf-binomial and sample-binomial
pdf-binomial and cdf-binomial

References:
http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/Binomial.html
Expand All @@ -1171,10 +1171,10 @@
Example:
(sample-binomial 1000 :prob 1/4 :size 20)
"
([^Integer size & {:keys [size prob] :or {size 1 prob 1/2}}]
(if (= size 1)
([^Integer samplesize & {:keys [size prob] :or {size 1 prob 1/2}}]
(if (= samplesize 1)
(Binomial/staticNextInt size prob)
(for [_ (range size)] (Binomial/staticNextInt size prob)))))
(repeatedly samplesize #(Binomial/staticNextInt size prob)))))



Expand Down Expand Up @@ -1267,7 +1267,7 @@
:lower-tail (default true)

See also:
cdf-poisson and sample-poisson
pdf-poisson and sample-poisson

References:
http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/Poisson.html
Expand Down Expand Up @@ -1353,7 +1353,7 @@
:lower-tail? (default true)

See also:
cdf-neg-binomial and sample-neg-binomial
pdf-neg-binomial and sample-neg-binomial

References:
http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/NegativeBinomial.html
Expand All @@ -1373,7 +1373,6 @@



;; TODO: may be this is a bug, that we have 2 size? in param and in options
(defn sample-neg-binomial
" Returns a sample of the given size from a Negative Binomial distribution.
Same as R's rnbinom
Expand All @@ -1392,10 +1391,10 @@
Example:
(sample-neg-binomial 1000 :prob 1/2 :size 20)
"
([^Integer nsize & {:keys [size prob] :or {size 10 prob 1/2}}]
(if (= size 1)
([^Integer samplesize & {:keys [size prob] :or {size 10 prob 1/2}}]
(if (= samplesize 1)
(NegativeBinomial/staticNextInt size prob)
(for [_ (range size)] (NegativeBinomial/staticNextInt size prob)))))
(repeatedly samplesize #(NegativeBinomial/staticNextInt size prob)))))



Expand Down