Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-feel/blob/main/tests/wolfram-duel.wl # omega-feel This project has not described itself yet. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-feel / tests / wolfram-duel.wl` 29 lines ยท 1875 bytes Raw Blame History 1 (* Count component: independent two-outcome pairs, assuming both sum conditions agree 2 with the count. Early rejection starts at nmin. Adoption is tested only at nmax. 3 Exact rational transition probabilities; no ties or adoption by mean in this model. *) 4 duel[p_, h_, nmin_, nmax_] := Module[{v, mid = nmax + 1, reject = 0, mean = 0, adopt}, 5 v = ConstantArray[0, 2 nmax + 1]; v[[mid]] = 1; 6 Do[ 7 mean += Total[v]; 8 v = p RotateRight[v] + (1 - p) RotateLeft[v]; 9 If[n >= nmin, 10 reject += Total[v[[1 ;; mid - h]]]; v[[1 ;; mid - h]] = 0], 11 {n, nmax}]; 12 adopt = Total[v[[mid + h ;;]]]; 13 {adopt, reject, 1 - adopt - reject, mean}]; 14 ps = {2/5, 9/20, 1/2, 11/20, 3/5, 7/10, 19/25}; 15 tab = Table[With[{r = duel[p, 12, 32, 256]}, {N[p], N[r[[1]], 6], N[r[[2]], 6], N[r[[3]], 6], N[r[[4]], 6]}], {p, ps}]; 16 (* chance the challenger wins a pair when it is faster by the fraction g and each launch has Gaussian noise s *) 17 pg[g_, s_] := CDF[NormalDistribution[], g/(s Sqrt[2])]; 18 ptab = Flatten[Table[{N[g], N[s], N[pg[g, s], 5]}, {g, {1/100, 2/100, 5/100, 10/100}}, {s, {1/100, 2/100, 5/100, 10/100}}], 1]; 19 htab = Table[{h, N[duel[9/20, h, 32, 256][[1]], 5], N[duel[11/20, h, 32, 256][[1]], 5], N[duel[11/20, h, 32, 256][[4]], 5]}, {h, {8, 12, 16, 20}}]; 20 f[x_Integer] := ToString[x]; 21 f[x_] := ToString[SetPrecision[x, 6], FortranForm]; 22 StringRiffle[Join[ 23 {"# count rule alone, h = 12, nmin = 32, nmax = 256: p = chance the challenger wins one pair", 24 "# columns: p P(adopt) P(reject) P(draw) mean pairs"}, 25 Map[StringRiffle[f /@ #, " "] &, tab], 26 {"# p from a gain g under per-launch Gaussian noise s: p = Phi(g / (s sqrt 2)). columns: g s p"}, 27 Map[StringRiffle[f /@ #, " "] &, ptab], 28 {"# choice of h (nmax = 256). columns: h P(adopt) at p = 0.45 P(adopt) at p = 0.55 mean pairs at p = 0.55"}, 29 Map[StringRiffle[f /@ #, " "] &, htab]], "\n"]