1.2.3-SNAPSHOT permalink Arrow_down_16x16

sample-normal

incanter.stats

  • (sample-normal size & options)
Returns a sample of the given size from a Normal distribution
This is equivalent to R's rnorm function.

Options:
:mean (default 0)
:sd (default 1)

See also:
pdf-normal, cdf-normal, quantile-normal

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

Example:
(sample-normal 1000 :mean -2 :sd (sqrt 0.5))

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:256 top

(defn sample-normal
" Returns a sample of the given size from a Normal distribution
  This is equivalent to R's rnorm function.

  Options:
    :mean (default 0)
    :sd (default 1)

  See also:
      pdf-normal, cdf-normal, quantile-normal

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

  Example:
      (sample-normal 1000 :mean -2 :sd (sqrt 0.5))
"
  ([^Integer size & options]
    (let [opts (when options (apply assoc {} options))
          mean (or (:mean opts) 0)
          sd (or (:sd opts) 1)]
      (if (= size 1)
        (Normal/staticNextDouble mean sd)
        (for [_ (range size)] (Normal/staticNextDouble mean sd))))))
Vars in incanter.stats/sample-normal: = defn for let
Used in 0 other vars

Comments top

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