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
%% schnorr grops | |
%% a basic sketch of zero-knowledge proofs [secret_sum/4] | |
%% 347, 173, 2 | |
% (+P, +Q, -G) | |
schnorr_generator(P, Q, G) :- | |
R is (P - 1) / Q, | |
min_h(P, Q, H), | |
G is powm(H, R, P). %% G = H^R mod P |
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
(def naive-model | |
"assuming that the 2 percent mortality rate applies to anyone who gets COVID19" | |
(let [world-population 8e9 | |
covid-mortality-rate 0.02 | |
percent-infected [0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1]] | |
(->> percent-infected | |
(map #(* % world-population)) | |
(map #(* % covid-mortality-rate))))) | |
(def severe-only-model |
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
(def naive-model | |
"assuming that the 2 percent mortality rate applies to anyone who gets COVID19" | |
(let [world-population 8e9 | |
covid-mortality-rate 0.02 | |
percent-infected [0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1]] | |
(->> percent-infected | |
(map #(* % world-population)) | |
(map #(* % covid-mortality-rate))))) | |
(def severe-only-model |
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
(declare _logistic-rec) | |
(defn logistic-rec [x r n] | |
(_logistic-rec x r n [])) | |
(defn _logistic-rec [x r n acc] | |
(if (= n 0) acc | |
(let [new-x (* r x (- 1 x))] | |
(_logistic-rec new-x r (dec n) (conj acc x))))) |
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
fmod LOGISTIC is | |
pr FLOAT . | |
pr LIST*{Float} . | |
vars X R : Float . | |
vars N : Nat . | |
var Acc : List{Float} . | |
op logistic : Float Float Nat -> List{Float} . | |
eq logistic(X, R, N) = $logistic(X, R, N, []) . |
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
logistic(X, R, N, Xs) :- | |
logistic_(X, R, N, [], Xs). | |
logistic_(_,_,0,Acc,Xs) :- !, flatten(Acc,Xs). | |
logistic_(X,R,N,Acc,Xs) :- | |
NewX is (R * X * (1 - X)), | |
NewN is N - 1, | |
logistic_(NewX,R,NewN, [Acc|X], Xs). | |
% :- logistic(0.2, 2.3, 10, Xs). |
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
(defn logistic [x r n] | |
(loop [x x | |
n n | |
xs []] | |
(if (= n 0) xs | |
(recur (* r x (- 1 x)) | |
(dec n) | |
(conj xs x))))) | |
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
||| key schedule | |
KS : DEAKey -> Vect 16 (Bits 48) | |
KS key = map PC2 | |
(tail (scanl (\prevKey, shift => | |
concat (map (rotateLeft shift) | |
(partition {m=28} {n=2} prevKey))) | |
(PC1 key) | |
[1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1])) |
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
(import (java.util.concurrent.ThreadLocalRandom)) | |
(defn exp [x n] | |
(loop [acc 1 n n] | |
(if (zero? n) acc | |
(recur (* x acc) (dec n))))) | |
(defn random-bigint [limit] | |
(let [bits (.bitLength limit)] | |
(loop [result (BigInteger. bits (java.util.concurrent.ThreadLocalRandom/current))] |
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
### Keybase proof | |
I hereby claim: | |
* I am hierophantos on github. | |
* I am hierophantos (https://keybase.io/hierophantos) on keybase. | |
* I have a public key ASCKQerxGEHJf_u-TZ0-0y1-M0PdKs3v1zQqKVpKi86ukgo | |
To claim this, I am signing this object: |
NewerOlder