1.2.3-SNAPSHOT Arrow_down_16x16

sample-neg-binomial

incanter.stats

  • (sample-neg-binomial size & options)
Returns a sample of the given size from a Negative Binomial distribution.
Same as R's rnbinom

Options:
:size (default 10)
:prob (default 1/2)

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

References:
http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/NegativeBinomial.html
http://en.wikipedia.org/wiki/Negative_binomial_distribution

Example:
(sample-neg-binomial 1000 :prob 1/2 :size 20)

0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source incanter/stats.clj:1370 top

(defn sample-neg-binomial
" Returns a sample of the given size from a Negative Binomial distribution.
  Same as R's rnbinom

  Options:
    :size (default 10)
    :prob (default 1/2)

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

  References:
      http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/NegativeBinomial.html
      http://en.wikipedia.org/wiki/Negative_binomial_distribution

  Example:
      (sample-neg-binomial 1000 :prob 1/2 :size 20)
"
([^Integer size & options]
    (let [opts (when options (apply assoc {} options))
          size (or (:size opts) 10)
          prob (or (:prob opts) 1/2)]
     (if (= size 1)
        (NegativeBinomial/staticNextInt size prob)
        (for [_ (range size)] (NegativeBinomial/staticNextInt size prob))))))
Vars in incanter.stats/sample-neg-binomial: = defn for let
Used in 0 other vars

Comments top

No comments for sample-neg-binomial. Log in to add a comment.