1.2.3-SNAPSHOT Arrow_down_16x16

sample-uniform

incanter.stats

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

Options:
:min (default 0)
:max (default 1)
:integers (default false)

See also:
pdf-uniform and cdf-uniform

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

Example:
(sample-uniform 1000)
(sample-uniform 1000 :min 1 :max 10)

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

(defn sample-uniform
" Returns a sample of the given size from a Uniform distribution.
  This is equivalent to R's runif function.

  Options:
    :min (default 0)
    :max (default 1)
    :integers (default false)

  See also:
      pdf-uniform and cdf-uniform

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

  Example:
      (sample-uniform 1000)
      (sample-uniform 1000 :min 1 :max 10)
"
([^Integer size & options]
    (let [opts (when options (apply assoc {} options))
          min-val (double (or (:min opts) 0.0))
          max-val (double (or (:max opts) 1.0))
          ints? (if (true? (:integers opts)) true false)
          dist (DoubleUniform. min-val max-val (DoubleMersenneTwister.))]
      (if (= size 1)
        (if ints?
          (DoubleUniform/staticNextIntFromTo min-val max-val)
          (DoubleUniform/staticNextDoubleFromTo min-val max-val))
        (if ints?
          (for [_ (range size)] (DoubleUniform/staticNextIntFromTo min-val max-val))
          (for [_ (range size)] (DoubleUniform/staticNextDoubleFromTo min-val max-val)))))))
Vars in incanter.stats/sample-uniform: = defn for let
Used in 0 other vars

Comments top

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