argmax NOW tiebreaks randomly
This commit is contained in:
parent
4fffe9e8f3
commit
d9171bcb51
@ -1,13 +1,22 @@
|
||||
(ns propeller.tools.metrics
|
||||
(:require [propeller.tools.math :as math]))
|
||||
|
||||
(defn argmax
|
||||
"returns the index of the maximum value in a list"
|
||||
(defn argmax-last
|
||||
"returns the index of the maximum value in a list, tiebreaking last"
|
||||
[coll]
|
||||
(->> coll
|
||||
(map-indexed vector)
|
||||
(apply max-key second)
|
||||
rand-nth))
|
||||
first))
|
||||
|
||||
(defn argmax
|
||||
"returns the index of the maximum value in a list, randomly tiebreaking"
|
||||
[coll]
|
||||
(->> coll
|
||||
(map-indexed vector)
|
||||
(filter #(= (apply max coll) (second %)))
|
||||
rand-nth
|
||||
first))
|
||||
|
||||
(defn mean
|
||||
"Returns the mean of a collection."
|
||||
|
Loading…
x
Reference in New Issue
Block a user