Created
October 29, 2010 00:27
-
-
Save jccc/652638 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 rand-seqn [prog size seed] | |
| (loop [ i 0 | |
| seqn [seed]] | |
| (if (>= i size) | |
| seqn | |
| (recur (inc i) | |
| (conj seqn (first | |
| (execute prog [(last seqn) 1.0 1.0 1.0]))))))) | |
| (defn- rev-map [ma] | |
| (reduce (fn [rev pair] (conj rev pair)) | |
| [] (map reverse (seq ma)))) | |
| (defn seqn-distr [size] | |
| (loop [ data {} | |
| seqn (rand-seqn (gen-rand 80) 10 1.0) | |
| cntr 0 ] | |
| (if (> cntr size) | |
| (sort (fn [a b] (> (first a) (first b))) (rev-map data)) | |
| (if (contains? data seqn) | |
| (recur (assoc data seqn (inc (data seqn))) | |
| (rand-seqn (gen-rand 80) 10 1.0) | |
| (inc cntr)) | |
| (recur (assoc data seqn 1) | |
| (rand-seqn (gen-rand 80) 10 1.0) | |
| (inc cntr)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment