1.2.3-SNAPSHOT permalink Arrow_down_16x16

quantile

incanter.stats

  • (quantile x & options)

Returns the quantiles of the data, x. By default it returns the min,
25th-percentile, 50th-percentile, 75th-percentile, and max value.

Options:
:probs (default [0.0 0.25 0.5 0.75 1.0])

Examples:
(quantile (sample-normal 100))
(quantile (sample-normal 100) :probs [0.025 0.975])
(quantile (sample-normal 100) :probs 0.975)

References:
http://incanter.org/docs/parallelcolt/api/cern/jet/stat/tdouble/DoubleDescriptive.html
http://en.wikipedia.org/wiki/Quantile

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

(defn quantile
"
  Returns the quantiles of the data, x. By default it returns the min,
  25th-percentile, 50th-percentile, 75th-percentile, and max value.

  Options:
    :probs (default [0.0 0.25 0.5 0.75 1.0])

  Examples:
    (quantile (sample-normal 100))
    (quantile (sample-normal 100) :probs [0.025 0.975])
    (quantile (sample-normal 100) :probs 0.975)

  References:
    http://incanter.org/docs/parallelcolt/api/cern/jet/stat/tdouble/DoubleDescriptive.html
    http://en.wikipedia.org/wiki/Quantile

"
  ([x & options]
    (let [opts (when options (apply assoc {} options))
          _x (to-list x)
          data (DoubleArrayList. (double-array (sort _x)))
          probs (cond
                  (number? (:probs opts))
                    (:probs opts)
                  (coll? (:probs opts))
                    (DoubleArrayList. (double-array (:probs opts)))
                  :default
                    (DoubleArrayList. (double-array [0.0 0.25 0.5 0.75 1.0])))]
        (if (number? probs)
          (DoubleDescriptive/quantile data probs)
          (seq (.elements (DoubleDescriptive/quantiles data probs)))))))
Vars in incanter.stats/quantile: defn let number? seq
Used in 0 other vars

Comments top

No comments for quantile. Log in to add a comment.