Skip to content

Instantly share code, notes, and snippets.

@nilspore
nilspore / entropy.clj
Created August 30, 2022 05:29 — forked from kyptin/entropy.clj
Shannon's entropy in Clojure
(defn entropy
"Calculate the Shannon entropy, a.k.a. amount of information, in a
distribution. Uses the log-base-2 version, so the result can be thought of as
the number of bits of information. Accepts either a seq of numbers or a map of
freqencies like that returned by the `clojure.core/freqencies` function.
Ex:
(entropy [1]) ; => 0.0
(entropy [0 1 0 1]) ; => 1.0
(entropy [0 1 2 3]) ; => 2.0
(entropy {0 2, 1 2}) ; => 1.0
(ns nilspore.draft.validator
(:require [clojure.core.async :as a]
[com.rpl.specter :as sp]
[integrant.core :as ig]
[nilspore.tools.core :as t]
[nilspore.tools.io :as tio]
[manifold.deferred]
[manifold.stream]
[clojure.spec.alpha :as s]
password = password
-----BEGIN PGP PRIVATE KEY BLOCK-----
lQdGBGNH0t0BEACt1vGgRS8fVyWBILGtknE1L0y/RXx6z6lQrlxHDn57CkCfvbow
mjR1tuveb9YkXHtus7ZHqWfLxiecFu/ZKC8m6r3zk3JbYpv15w+iTe8obPL8l+uE
K9xjFH6CjePnRoYQox+xVrWFYVsqxNJvXcXIdepPz1GXOXo8A6CiD9luTX0Vcmxm
IWpeNWXeJA6u1RP0Qu4nCItnvKpnONA8NY6cKg+KSnF6bJgo8oUptBKdv06tat1w
t62HoIr3xw/j1nYJHvnR3bl9Jfc9kwpRDeiFc/rEa0yEa4C4IbRnd+6OVRx0nGSu
/7qGBmExlERJy0jxM5FngXpGMtnGbF9XVZx/aeQozqMRzutvcNVXd08IRMHeY0ql
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBGNH0t0BEACt1vGgRS8fVyWBILGtknE1L0y/RXx6z6lQrlxHDn57CkCfvbow
mjR1tuveb9YkXHtus7ZHqWfLxiecFu/ZKC8m6r3zk3JbYpv15w+iTe8obPL8l+uE
K9xjFH6CjePnRoYQox+xVrWFYVsqxNJvXcXIdepPz1GXOXo8A6CiD9luTX0Vcmxm
IWpeNWXeJA6u1RP0Qu4nCItnvKpnONA8NY6cKg+KSnF6bJgo8oUptBKdv06tat1w
t62HoIr3xw/j1nYJHvnR3bl9Jfc9kwpRDeiFc/rEa0yEa4C4IbRnd+6OVRx0nGSu
/7qGBmExlERJy0jxM5FngXpGMtnGbF9XVZx/aeQozqMRzutvcNVXd08IRMHeY0ql
L1FxOtidnk9Ok3bXD7z45tPmrt6YAMMUxaEVxhLrF+mGST87sV7fMDRUdImWDtuG
i6JFdFTATOPLzmlyzEd5jYHvj2Igje4dUN59QViTUIOTcSWoi1f1L6L6ZJFAKBD9