Skip to content

Instantly share code, notes, and snippets.

@triss
Created October 13, 2016 21:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save triss/9771941b14a325b79b09b06480b32670 to your computer and use it in GitHub Desktop.
Save triss/9771941b14a325b79b09b06480b32670 to your computer and use it in GitHub Desktop.
IDEA implimentation
(ns idea.core)
(defn rand-audience
"Generates a random audience with n members."
[n] (repeatedly n (fn [] {:well-being (dec (rand 2))
:effort (rand)})))
(defn measure-audience
"apply f to every item in audience, and average and weight the result."
[weight f audience]
(let [n (count audience)]
(->> audience
(map f)
(reduce +)
(/ n)
(* weight))))
(def disgust
(partial measure-audience 1/2 #(- 1 (:well-being %))))
(def indifference
(comp #(- 1 %) (partial measure-audience 1 :well-being)))
(def popularity
(partial measure-audience 1/2 #(inc (:well-being %))))
(def provocation
(partial measure-audience 1 :effort))
(defn divisiveness
[audience]
(let [n (count audience)
m (/ (reduce + (map :well-being audience)) n)]
(->> audience
(map #(- (:well-being %) m))
(reduce +)
(/ n))))
(defn acquired-taste
[a] (/ (+ (popularity a) (provocation a)) 2))
(defn instant-appeal
[a] (/ (inc (- (popularity a) (provocation a))) 2))
(defn opinion-splitting
[a] (/ (inc (- (divisiveness a) (provocation a))) 2))
(defn opinion-forming
[a] (/ (+ (divisiveness a) (provocation a)) 2))
(defn shock
[a] (/ (inc (- (disgust a) (provocation a))) 2))
(defn subversion
[a] (/ (+ (disgust a) (provocation a)) 2))
(defn triviality
[a] (/ (inc (- (disgust a) (provocation a))) 2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment