Skip to content

Commit

Permalink
Clean up simplicity calculation.
Browse files Browse the repository at this point in the history
  • Loading branch information
lynaghk committed Mar 23, 2012
1 parent c4f1716 commit 9e1da7e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/clj/c2/ticks.clj
Expand Up @@ -15,19 +15,20 @@
(first (for [[idx y] (map-indexed vector coll)
:when (= y x)] idx)))

(defn label-range-contains-zero? [l-min l-max l-step]
(and (> l-max 0) (< l-min 0) (zero? (mod l-min l-step))))

(defn simplicity
"Objective function modeling niceness of step sizes and whether a range includes zero."
[q Q j l-min l-max l-step]
(let [v ;;Does the range contain zero?
(and (> l-max 0)
(< l-min 0)
(zero? (mod l-min l-step)))]
[q Q j label-range-contains-zero]
(let [v (if label-range-contains-zero 1 0)]
(if (<= (count Q) 1)
(+ (- 1 j) v)
(+ (- 1 (/ (index-of q Q) (dec (count Q))) j)
v))))

(defn max-simplicity [q Q j] (simplicity q Q j true))

(defn coverage
"Objective function based on distances between extreme data and extreme labels"
[d-min d-max l-min l-max]
Expand Down

0 comments on commit 9e1da7e

Please sign in to comment.