Skip to content

Instantly share code, notes, and snippets.

View favila's full-sized avatar

Francis Avila favila

View GitHub Profile
;; 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)]
@favila
favila / ci_lower_bound.sql
Last active July 24, 2022 17:41 — forked from anonymous/ci_lower_bound.sql
MySQL stored functions for calculating confidence intervals using Wilson scores: more precisely "Lower bound of Wilson score confidence interval for a Bernoulli parameter". Includes a P(qn) function (inverse normal distribution). See http://www.evanmiller.org/how-not-to-sort-by-average-rating.html This describes a way to rank items based on a ve…
# 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