Added a file to render the result of the probability experiment.
authorJohannes Middeke <j-middeke@t-online.de>
Thu, 5 May 2016 16:55:05 +0000 (12:55 -0400)
committerJohannes Middeke <j-middeke@t-online.de>
Thu, 5 May 2016 16:55:05 +0000 (12:55 -0400)
makeHTMLprobability.ml [new file with mode: 0644]

diff --git a/makeHTMLprobability.ml b/makeHTMLprobability.ml
new file mode 100644 (file)
index 0000000..6c94e7e
--- /dev/null
@@ -0,0 +1,56 @@
+#use "topfind";;
+#require "tools";;
+#use "commonSVG.ml";;
+
+(* The data from the GCD experiment: *)
+
+let data = [1,24.79; 2,31.24; 3,33.56; 4,33.75; 5,33.24; 6,33.48; 7,34.32; 8,32.09; 9,32.89; 10,33.11; 11,33.34; 12,33.43; 13,33.76; 14,33.67; 15,33.41; 16,33.78; 17,32.08; 18,33.64; 19,33.00; 20,33.61; 21,33.22; 22,34.21; 23,33.77; 24,32.64; 25,32.82; 26,32.99; 27,33.72; 28,33.71; 29,33.73; 30,33.37; 31,33.68; 32,33.66; 33,32.99; 34,32.88; 35,33.70; 36,33.05; 37,33.66; 38,33.10; 39,32.91; 40,32.68; 41,32.89; 42,32.99; 43,34.05; 44,33.62; 45,34.33; 46,32.94; 47,32.98; 48,33.40; 49,33.06; 50,33.21; 51,33.63; 52,33.99; 53,33.17; 54,32.84; 55,33.29; 56,33.34; 57,33.49; 58,32.81; 59,32.75; 60,33.04; 61,33.62; 62,33.68]
+
+let average = List.map snd data |> Statistics.mean
+
+(* (List.map snd data |> List.fold_left (+.) 0.) /. float
+   (List.length data) *)
+
+
+let description () = Printf.printf "</svg>
+
+<script type=\"text/javascript\" async
+        src=\"https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML\">
+</script>
+
+<p>
+  This graph shows the probability that $$\\frac{\\gcd(a,b)}{\\gcd(a,b,c)}$$
+  is non-trivial for randomly chosen \\(a,b,c \\in \\mathrm{GF}(2)[x]\\)
+  of degree at most \\(n\\). For each degree we used 10.000 samples.
+</p>
+
+<p>
+  The average probability was %.2f%%.
+</p>" average
+
+   
+   let main total predict =
+   let coords = map_coords ~width:100. ~height:100. in
+   head "Non-Trivial Prediction" "Non-Trivial Prediction over GF(2)[<i>x</i>]";
+   defs total predict;
+   ticks coords ~x:65 ~step_x:5 ~y:90 ~step_y:10 ();
+   axes "<tspan font-style=\"italic\">n</tspan>" "Probability";
+   let (x1,y1) = coords (0.,average) and (x2,y2) = coords (100.,average) in
+   Printf.printf "<path d=\"M%.2f,%.2f L%.2f,%.2f\" stroke=\"%s\"
+   stroke-width=\"0.5\"/>"
+   x1 y1 x2 y2 predict;
+   Printf.printf "<text x=\"%.2f\" y=\"%.2f\" fill=\"%s\" 
+   text-anchor=\"end\" font-size=\"12px\">
+   %.2f%%
+   </text>" 
+   x2 y2 predict average;
+   data
+   |> List.map (fun (n,t) -> (float n, t))
+   |> graph coords total "probability";
+   description ();
+   foot ()
+
+
+(* "#353E5E" "#661B1B"*)
+    
+let () = main "#353E5E" "#C2A5A5"