1.2.3-SNAPSHOT Arrow_down_16x16

sample-binomial

incanter.stats

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

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

See also:
cdf-binomial and sample-binomial

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

Example:
(sample-binomial 1000 :prob 1/4 :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:1132 top

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

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

  See also:
      cdf-binomial and sample-binomial

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

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

Comments top

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