This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; same thing using reduction over d/datoms. | |
;; Objective is to avoid realizing too much in memory | |
;; May still be slow, but won't OOM | |
(defn orgs->max-fks [db] | |
(reduce (fn [o->fk [content-eid _ content-fk]] | |
(let [org-id (-> (d/entity db content-eid) | |
:content/collection | |
:collection/organization | |
:db/id)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Francis Avila 2009-07-04 | |
# See http://www.evanmiller.org/how-not-to-sort-by-average-rating.html | |
# These functions calculate "Lower bound of Wilson score confidence interval for a Bernoulli parameter" | |
# Two stored functions: | |
# CI_LOWER_BOUND(pos, trials, confidence) calculate a wilson score given POS positive votes in TRIALS number of trials | |
# PNORM(qn) calculate P(qn) (inverse normal distribution); needed by CI_LOWER_BOUND | |
delimiter ;; | |
CREATE DEFINER=`root`@`localhost` FUNCTION `ci_lower_bound`(pos INTEGER, trials INTEGER, confidence DOUBLE) RETURNS double | |
NO SQL |