Skip to content

Instantly share code, notes, and snippets.

@guyhughes
Created August 15, 2017 15:39
Show Gist options
  • Save guyhughes/521c6942f0746ee1955fe15f7f6e8531 to your computer and use it in GitHub Desktop.
Save guyhughes/521c6942f0746ee1955fe15f7f6e8531 to your computer and use it in GitHub Desktop.
DoS
In [42]: def f(n):
...: compl= (sympy.functions.combinatorial.factorials.factorial(n) * sympy.functions.combinatorial.factorials.binomial(SIZE, n) / mp.power(SIZE, n) )
...: p = 1 - compl
...: return p
...:
...:
In [43]: for i in range(10,SIZE*10, 50):
...: p = f(i)
...: print(i, p)
...: if p == 1.0: break
...:
10 0.000449922006149794
60 0.0175480729944565
110 0.0582101266172803
160 0.119504294802539
210 0.197166396615447
260 0.286089996272573
310 0.380878958515124
360 0.476379824410914
410 0.568122652385172
460 0.652622045281599
510 0.727518902045753
560 0.791571393984298
610 0.844525346907527
660 0.886906484261314
710 0.919779354596536
760 0.944511953933143
810 0.962574118637897
860 0.975385078773093
910 0.984213961688216
960 0.990128330271699
1010 0.993980709384245
1060 0.996421247207679
1110 0.997925352877772
1160 0.998827325780647
1210 0.999353712785549
1260 0.999652717228639
1310 0.999818053026988
1360 0.999907059547662
1410 0.999953713163146
1460 0.999977525118225
1510 0.999989360556016
1560 0.999995089604662
1610 0.999997790548893
1660 0.999999030791671
1710 0.999999585514756
1760 0.999999827195683
1810 0.999999929765894
1860 0.999999972171881
1910 0.999999989251290
1960 0.999999995952751
2010 0.999999998514445
2060 0.999999999468458
2110 0.999999999814604
2160 0.999999999936966
2210 0.999999999979110
2260 0.999999999993251
2310 0.999999999997875
2360 0.999999999999348
2410 0.999999999999805
2460 0.999999999999943
2510 0.999999999999984
2560 0.999999999999996
2610 0.999999999999999
2660 1.00000000000000
2710 1.00000000000000
2760 1.00000000000000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment