1.2.3-SNAPSHOT permalink Arrow_down_16x16

cdf-empirical

incanter.stats

  • (cdf-empirical x)
Returns a step-function representing the empirical cdf of the given data.
Equivalent to R's ecdf function.

The following description is from the ecdf help in R: The e.c.d.f.
(empirical cumulative distribution function) Fn is a step function
with jumps i/n at observation values, where i is the number of tied
observations at that value. Missing values are ignored.

For observations 'x'= (x1,x2, ... xn), Fn is the fraction of
observations less or equal to t, i.e.,

Fn(t) = #{x_i <= t} / n = 1/n sum(i=1,n) Indicator(xi <= t).


Examples:
(use '(incanter core stats charts))

(def exam1 [192 160 183 136 162 165 181 188 150 163 192 164 184
189 183 181 188 191 190 184 171 177 125 192 149 188
154 151 159 141 171 153 169 168 168 157 160 190 166 150])

;; the ecdf function returns an empirical cdf function for the given data
(def ecdf (cdf-empirical exam1))

;; plot the data's empircal cdf
(view (scatter-plot exam1 (map ecdf exam1)))



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

(defn cdf-empirical
" Returns a step-function representing the empirical cdf of the given data.
  Equivalent to R's ecdf function.

  The following description is from the ecdf help in R: The e.c.d.f.
  (empirical cumulative distribution function) Fn is a step function
  with jumps i/n at observation values, where i is the number of tied
  observations at that value.  Missing values are ignored.

  For observations 'x'= (x1,x2, ... xn), Fn is the fraction of
  observations less or equal to t, i.e.,

  Fn(t) = #{x_i <= t} / n  =  1/n sum(i=1,n) Indicator(xi <= t).


  Examples:
    (use '(incanter core stats charts))

    (def exam1 [192 160 183 136 162 165 181 188 150 163 192 164 184
                189 183 181 188 191 190 184 171 177 125 192 149 188
                154 151 159 141 171 153 169 168 168 157 160 190 166 150])

    ;; the ecdf function returns an empirical cdf function for the given data
    (def ecdf (cdf-empirical exam1))

    ;; plot the data's empircal cdf
    (view (scatter-plot exam1 (map ecdf exam1)))



"
  ([x] (fn [t] (div (sum (indicator #(<= % t) x)) (count x)))))
Vars in incanter.stats/cdf-empirical: <= count defn fn
Used in 0 other vars

Comments top

No comments for cdf-empirical. Log in to add a comment.