Mercurial > rlm
changeset 8:7240d7a5f959
random files :)
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Thu, 19 Jul 2012 10:56:39 -0500 |
parents | b4395ca99822 |
children | 1065e7d615a4 |
files | src/rlm/crypt_addition.clj src/rlm/jen.clj |
diffstat | 2 files changed, 146 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/rlm/crypt_addition.clj Thu Jul 19 10:56:39 2012 -0500 1.3 @@ -0,0 +1,10 @@ 1.4 +(ns rlm.crypt-addition) 1.5 + 1.6 + 1.7 +(defn symbol-crypt 1.8 + [syms-1 syms-2 resuts] 1.9 + 1.10 + 1.11 + 1.12 + 1.13 + ) 1.14 \ No newline at end of file
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/src/rlm/jen.clj Thu Jul 19 10:56:39 2012 -0500 2.3 @@ -0,0 +1,136 @@ 2.4 +(ns rlm.jen) 2.5 + 2.6 +(defn select-cells [n total-groups] 2.7 + (map (fn [_] (int (* total-groups (Math/random)))) (range n))) 2.8 + 2.9 +(defn all-selected? [selections n] 2.10 + (= n (count (set selections)))) 2.11 + 2.12 +(defn probability-of-all-selected 2.13 + [n desired total-groups total-trials] 2.14 + (let [trials 2.15 + (map (fn [_] 2.16 + (all-selected? 2.17 + (select-cells n total-groups) desired)) 2.18 + (range total-trials)) 2.19 + prob 2.20 + (/ (count (filter identity trials)) total-trials)] 2.21 + prob)) 2.22 + 2.23 +(defn your-problem [up-to trials-per-test] 2.24 + (print "selections probability of getting all 15\n") 2.25 + (dorun 2.26 + (map 2.27 + (fn [n] 2.28 + (let [prob 2.29 + (probability-of-all-selected 2.30 + n 15 15 trials-per-test)] 2.31 + (printf "%10d %1.3f\n" n (float prob)))) 2.32 + (range up-to)))) 2.33 + 2.34 + 2.35 +;; rlm.jen> (your-problem 100 1000) 2.36 +;; selections probability of getting all 15 2.37 +;; 0 0.000 2.38 +;; 1 0.000 2.39 +;; 2 0.000 2.40 +;; 3 0.000 2.41 +;; 4 0.000 2.42 +;; 5 0.000 2.43 +;; 6 0.000 2.44 +;; 7 0.000 2.45 +;; 8 0.000 2.46 +;; 9 0.000 2.47 +;; 10 0.000 2.48 +;; 11 0.000 2.49 +;; 12 0.000 2.50 +;; 13 0.000 2.51 +;; 14 0.000 2.52 +;; 15 0.000 2.53 +;; 16 0.000 2.54 +;; 17 0.000 2.55 +;; 18 0.001 2.56 +;; 19 0.000 2.57 +;; 20 0.001 2.58 +;; 21 0.004 2.59 +;; 22 0.005 2.60 +;; 23 0.012 2.61 +;; 24 0.008 2.62 +;; 25 0.028 2.63 +;; 26 0.031 2.64 +;; 27 0.049 2.65 +;; 28 0.045 2.66 +;; 29 0.056 2.67 +;; 30 0.100 2.68 +;; 31 0.113 2.69 +;; 32 0.125 2.70 +;; 33 0.159 2.71 +;; 34 0.152 2.72 +;; 35 0.203 2.73 +;; 36 0.216 2.74 +;; 37 0.259 2.75 +;; 38 0.285 2.76 +;; 39 0.283 2.77 +;; 40 0.331 2.78 +;; 41 0.371 2.79 +;; 42 0.420 2.80 +;; 43 0.421 2.81 +;; 44 0.456 2.82 +;; 45 0.491 2.83 +;; 46 0.527 2.84 +;; 47 0.558 2.85 +;; 48 0.534 2.86 +;; 49 0.568 2.87 +;; 50 0.580 2.88 +;; 51 0.605 2.89 +;; 52 0.668 2.90 +;; 53 0.676 2.91 +;; 54 0.678 2.92 +;; 55 0.706 2.93 +;; 56 0.726 2.94 +;; 57 0.732 2.95 +;; 58 0.743 2.96 +;; 59 0.755 2.97 +;; 60 0.761 2.98 +;; 61 0.789 2.99 +;; 62 0.804 2.100 +;; 63 0.798 2.101 +;; 64 0.837 2.102 +;; 65 0.825 2.103 +;; 66 0.832 2.104 +;; 67 0.865 2.105 +;; 68 0.871 2.106 +;; 69 0.880 2.107 +;; 70 0.894 2.108 +;; 71 0.892 2.109 +;; 72 0.892 2.110 +;; 73 0.903 2.111 +;; 74 0.911 2.112 +;; 75 0.917 2.113 +;; 76 0.926 2.114 +;; 77 0.937 2.115 +;; 78 0.922 2.116 +;; 79 0.942 2.117 +;; 80 0.927 2.118 +;; 81 0.936 2.119 +;; 82 0.952 2.120 +;; 83 0.952 2.121 +;; 84 0.960 2.122 +;; 85 0.973 2.123 +;; 86 0.969 2.124 +;; 87 0.952 2.125 +;; 88 0.963 2.126 +;; 89 0.973 2.127 +;; 90 0.971 2.128 +;; 91 0.969 2.129 +;; 92 0.980 2.130 +;; 93 0.968 2.131 +;; 94 0.975 2.132 +;; 95 0.991 2.133 +;; 96 0.980 2.134 +;; 97 0.977 2.135 +;; 98 0.982 2.136 +;; 99 0.988 2.137 +;; nil 2.138 + 2.139 +