1.2.3-SNAPSHOT Arrow_down_16x16

indicator

incanter.stats

  • (indicator pred coll)

Returns a sequence of ones and zeros, where ones
are returned when the given predicate is true for
corresponding element in the given collection, and
zero otherwise.

Examples:
(use 'incanter.stats)

(indicator #(neg? %) (sample-normal 10))

;; return the sum of the positive values in a normal sample
(def x (sample-normal 100))
(sum (mult x (indicator #(pos? %) x)))

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

(defn indicator
"
  Returns a sequence of ones and zeros, where ones
  are returned when the given predicate is true for
  corresponding element in the given collection, and
  zero otherwise.

  Examples:
    (use 'incanter.stats)

    (indicator #(neg? %) (sample-normal 10))

    ;; return the sum of the positive values in a normal sample
    (def x (sample-normal 100))
    (sum (mult x (indicator #(pos? %) x)))

"
  ([pred coll]
    (for [el coll] (if (pred el) 1 0))))
Vars in incanter.stats/indicator: defn for
Used in 0 other vars

Comments top

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