1.2.3-SNAPSHOT Arrow_down_16x16

quantile-t

incanter.stats

  • (quantile-t probability & options)
Returns the inverse of the Student's t CDF for the given probability
(i.e. the quantile). It will return a sequence of values, if x is
a sequence of probabilities. This is equivalent to R's qt function.

Options:
:df (default 1)

Returns:
a value x, where (cdf-t x) = probability

See also:
pdf-t, cdf-t, and sample-t

References:
http://incanter.org/docs/parallelcolt/api/cern/jet/stat/tdouble/Probability.html
http://en.wikipedia.org/wiki/Student-t_distribution
http://en.wikipedia.org/wiki/Quantile

Example:
(quantile-t 0.975)
(quantile-t [0.025 0.975] :df 25)
(def df [1 2 3 4 5 6 7 8 9 10 20 50 100 1000])
(map #(quantile-t 0.025 :df %) df)

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

(defn quantile-t
" Returns the inverse of the Student's t CDF for the given probability
  (i.e. the quantile).  It will return a sequence of values, if x is
  a sequence of probabilities. This is equivalent to R's qt function.

  Options:
    :df (default 1)

  Returns:
    a value x, where (cdf-t x) = probability

  See also:
     pdf-t, cdf-t, and sample-t

  References:
      http://incanter.org/docs/parallelcolt/api/cern/jet/stat/tdouble/Probability.html
      http://en.wikipedia.org/wiki/Student-t_distribution
      http://en.wikipedia.org/wiki/Quantile

  Example:
      (quantile-t 0.975)
      (quantile-t [0.025 0.975] :df 25)
      (def df [1 2 3 4 5 6 7 8 9 10 20 50 100 1000])
      (map #(quantile-t 0.025 :df %) df)
"
  ([probability & options]
    (let [opts (when options (apply assoc {} options))
          df (or (:df opts) 1)
          to-alpha (fn [prob] ;; need to convert the probability to an alpha value
                     (if (< prob 1/2)
                      (* 2 prob)
                      (* 2 (- 1 prob))))
          sign-fx (fn [x1 prob] (if (< prob 1/2) (* -1 x1) x1))
          x (if (coll? probability)
              (map #(sign-fx (Probability/studentTInverse (to-alpha %) df) %) probability)
              (sign-fx (Probability/studentTInverse (to-alpha probability) df) probability))]
        x)))
Vars in incanter.stats/quantile-t: defn let
Used in 0 other vars

Comments top

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