PO8

Social Engineering: Theory and Practice

PO8
May 14th, 2016
434
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 27.44 KB | None | 0 0
  1. Social Engineering: Theory and Practice
  2. March 23, 1997
  3.  
  4. The Netrunner runner Prep card Social Engineering is an oft-used
  5. card: it provides both an early-game speedup and a way of
  6. dealing with particularly nasty ice in the late game. It,
  7. along with its early-game counterpart Inside Job, is an
  8. important runner-deck tool. However, Social Engineering
  9. suffers somewhat from a bad reputation. It is all too easy for
  10. the runner to lose more bits than they can afford at a critical
  11. time during the game. And yet, if the Runner risks too few
  12. bits, the chances of success are not very high.
  13.  
  14. The inventors of the branch of Mathematics known as Game Theory
  15. wanted to answering these very sorts of economic questions.
  16. Game Theory can tell us exactly how to play Social Engineering
  17. optimally in a given situation. In this article, I will
  18. describe these optimal strategies for Social Engineering, and
  19. give some suggestions about how to convert this theory into
  20. practice.
  21.  
  22. Here's the rules for Social Engineering, as taken from
  23. BitByte's (<[email protected]>) spoiler list
  24. (http://home.pacific.net.sg/~bitbyte).
  25.  
  26. Social Engineering: Prep (1) [1.0 U]
  27. Hide at least (2) from your pool in your hand; the Corp
  28. then guesses how many bits you hid. If the Corp guesses
  29. correctly, lose that many bits. Otherwise, choose a
  30. data fort and a piece of ICE on that fort. Then make a
  31. run on that fort, during which you automatically pass
  32. that piece of ICE.
  33.  
  34. Assume a pool of n bits. Then, let us choose to risk i bits
  35. [2 <= i <= n] with probability proportional to 1/i. We must
  36. normalize, so we are chosing to risk i bits with probability
  37. p(i) = (1/i) / (1/2 + 1/3 + ... + 1/n)
  38. Thus, when n = 5, we have probabilities
  39. i p(i)
  40. 2 0.39
  41. 3 0.26
  42. 4 0.19
  43. 5 0.15
  44. Now imagine that the corp chooses any pure strategy (i.e., it
  45. always guesses some particular number of bits). Its expected
  46. return on this strategy (i.e., the number of bits it expects to
  47. cost the runner due to guessing correctly) is identical.
  48. i e(i)
  49. 2 0.78
  50. 3 0.78
  51. 4 0.78
  52. 5 0.78
  53. In other words, no matter what pure strategy the corp picks, it
  54. will cost the runner 1.78 bits, on average, to play social
  55. engineering. It can be proven from this that any combination of
  56. pure corp strategies will achieve the same result, and thus
  57. this strategy is optimal for the runner (although the proof
  58. is outside the scope of this paper).
  59.  
  60. Unfortunately, the above "optimal" strategy is based on a
  61. fairly unrealistic assumption. Presumably the runner
  62. is playing this card because they will receive some utility
  63. from a successful run, not just to avoid losing bits.
  64. Unfortunately, there is no clear "value of being able to pass a
  65. selected piece of ice" in the game. Let us arbitrarily set
  66. this value at 3 bits, just to see how it affects our
  67. calculations. (Why 3 bits? Inside Job, which costs 2 bits,
  68. will let us pass the 1st piece of ice for free. Let us assume
  69. that the value of passing an arbitrary piece of ice is half
  70. again as much. We will generalize later in any case.)
  71.  
  72. We will now use a different strategy, namely; we will risk i
  73. bits with probability 1/i+3. Normalizing gives us
  74. p(i) = (1/(i+3)) / (1/5 + 1/6 + ... + 1/(n+3))
  75. When n = 5, we choose with probability
  76. i p(i)
  77. 2 0.32
  78. 3 0.26
  79. 4 0.23
  80. 5 0.20
  81. and the corp's expected return for their pure strategy
  82. (including the three bit benefit of preventing the run
  83. as well as the cost to the runner of being guessed and of
  84. playing the card) is
  85. i e(i)
  86. 2 2.6
  87. 3 2.6
  88. 4 2.6
  89. 5 2.6
  90. Thus, we have an optimal strategy for the runner under the new
  91. conditions, under which it will cost the runner about 2.6 bits,
  92. including the opportunity cost of missed runs, to play Inside
  93. Job. (There is some additional opportunity cost of playing a
  94. Prep during the run, but this is difficult to estimate and
  95. probably reasonably small in any case.) Note how much the
  96. probabilities have flattened out. Indeed, as the value to the
  97. corp of an unsuccessful run gets large, it swamps the expected
  98. value of making the runner lose the guess bits, and the
  99. runner's optimal strategy quickly converges on simply picking a
  100. random value uniformly from the range 2..n .
  101.  
  102. A natural question to ask about strategy involves asymptotic
  103. behavior: what is the optimal strategy as the size of the
  104. runner's bit pool n gets large?
  105. limit n->inf sum(i=2..n, 1/i)
  106. diverges, so the more bits the runner has, the better off they
  107. are. Notice that the expected return for the corp as a function
  108. of the runner's bit pool size n is
  109. e(n) = 1 + 1/(1/5 + 1/6 + ... + 1/(n+3))
  110. Obviously, the expected corp return converges on 1. But don't
  111. be fooled: the divergence of this "harmonic series" is notoriously
  112. slow. When n = 100 (surely infinity from most corps' point
  113. of view) we still have e(n)=1.32 .
  114.  
  115. Note that we picked a utility of 3 for a successful run fairly
  116. arbitrarily. Depending on the game situation, this utility
  117. estimate could be wildly off. E.g., you know there's a
  118. Political Overthrow in a fort, and it's protected by
  119. Filter-Filter-Colonel Failure. Your icebreakers are Codecracker
  120. and Raptor. How much would you be willing to pay for a
  121. Social? On the other hand, a Filter protects a Holovid
  122. Campaign, but you don't have any icebreakers yet. How much
  123. would you be willing to pay for a Social?
  124.  
  125. Fortunately, the calculations we have been performing
  126. generalize quite easily to the case of a u-bit utility:
  127. p(i,n,u) = (1/(i+u)) / (1/(2+u) + 1/(3+u) + ... + 1/(n+u))
  128. e(n,u) = 1 + 1/(1/(2+u) + 1/(3+u) + ... + 1/(n+u))
  129. One interesting way to pick the utility is to ask the card itself
  130. how much it values a run at! We do this by noting that the
  131. card is presumably zero-sum, and thus when e(n,u) = u presumably
  132. the corp expects to cost the runner exactly the amount that the
  133. runner expects to benefit from the run. Thus we need to solve
  134. 1 + 1/(1/(2+u) + 1/(3+u) + ... + 1/(n+u)) = u
  135. i.e.
  136. (1/(2+u) + 1/(3+u) + ... + 1/(n+u)) = 1/(u-1)
  137. for u. I don't see how to do this analytically, but numerically,
  138. we find the following:
  139. n u
  140. 2 *
  141. 3 4.5
  142. 4 3.0
  143. 5 2.4
  144. 6 2.1
  145. 7 2.0
  146. 8 1.9
  147. 9 1.8
  148. 10 1.8
  149. ...
  150. 100 1.3
  151. The * at n = 2 is because the equation for u is singular
  152. at this value, and thus no solution exists. Intuitively, this
  153. is because the corp will never guess wrong in this case, and so
  154. the runner is stupid to play the card! The fact that the u
  155. value is dependent on the size n of the runner bit pool is
  156. rather strange, but points up the fact that as the runner has
  157. more bits, his chances of using this card successfully just get
  158. better and better, and so a run made using the card is worth
  159. less and less.
  160.  
  161. Note that once the runner has 6 or more bits, the expected
  162. return when playing optimally (at u=3) doesn't change much as
  163. the bit pool increases. However, what does change is the risk
  164. of a disastrous outcome for the runner. It is true that the
  165. expected return for the corp if it always chooses n is exactly
  166. the same as if it always chooses 2. However, in the first
  167. case, if the corp guesses right, the runner loses all their
  168. bits. This will happen very rarely, but the runner may be
  169. risk-averse; willing to lose more on average to avoid the risk
  170. of major losses. Fortunately, limiting risk in this framework
  171. is easily accomplished: the runner can treat the pool as though
  172. it has only as many bits as the runner is willing to risk, and
  173. calculate accordingly. Again, the cost of this risk management
  174. becomes very high at 4 bits or below, and I don't advise it ---
  175. if losing 4 bits would be a disaster for the runner, the runner
  176. shouldn't be playing a Social Engineering at that point.
  177.  
  178. A final question is how to use our formulae in a game situation.
  179. If one is playing online, it's relatively straightforward to
  180. have a "Social Engineering bit picker" sitting in a window on
  181. one's terminal, which will select bit value b(n,u) from the
  182. appropriate probability distribution p(i,n,u). If one is
  183. playing head-to-head, it is possible to program a programmable
  184. calculator, PDA, etc., to perform this same calculation.
  185. Unfortunately, this may or may not be allowed by a tournament
  186. director, and it may be cumbersome and unpleasant in any case.
  187.  
  188. Lacking a programmable calculator or PDA, the runner could use
  189. a set of tables for d100, parameterized by n and u, to select
  190. bit values. These tables are included as Appendix A to this
  191. article. In fact, since it is highly desirable to screen the
  192. die roll used for this selection from the runner, a very
  193. reasonable approach is to glue the tables to the inside of a
  194. cardboard screen, behind which the dice are rolled and the bits
  195. selected.
  196.  
  197. What is really desired is an approximation or set of
  198. approximations using just ordinary die rolls and no difficult
  199. arithmetic, such that a selection reasonable approximating
  200. optimality can be quickly and unobtrusively carried out in a
  201. game situation. Unfortunately, I see no obvious rules of thumb
  202. for small n and/or u. For u >= 4 and n >= 5, however, it
  203. appears that the error induced by merely rolling a die and
  204. guessing as many bits as it says (rerolling if it is out of
  205. range) is fairly small. We can quantify the cost of this
  206. non-optimal strategy. The expected return for the corp is
  207. c(i) = (1 + i + u) * (1/(n-1) - p(i))
  208. where p(i) is the true probability that should be assigned to
  209. the i-th bit. It is clear that the corp's best bet is always
  210. to take i=n, and that the largest error obtains when u=4. It
  211. turns out that the error gets larger as n increases (which
  212. makes intuitive sense, since the runner is supposed to be
  213. getting a better and better deal, and isn't) but stays
  214. very close to 1/2 bit for a wide range of n and u values
  215. above n >= 5 and u >= 4. This is another interesting consequence
  216. of the slow divergence of the harmonic series --- we know that
  217. the error becomes infinite for large enough n, but when n=100,
  218. we still have error less than 0.72!
  219.  
  220. One unfortunate effect of this strategy, however, is that the
  221. optimal corp strategy is to guess the entire value of the bit
  222. pool. This might make a risk-averse runner very nervous,
  223. especially since this corp strategy gets slightly better as the
  224. size of the runner bit pool increases. An obvious way to
  225. counter this problem is to count die rolls of 1 as 2s: this
  226. overweights the value 2 at the expense of the other values. It
  227. turns out that the optimal corp strategy (again for n >= 5 and
  228. u >=4) is now to always guess 2. Fortunately, the expected
  229. corp gain over optimal strategy is still about 1/2 bit, and
  230. falls rapidly off as n increases (for fixed u).
  231.  
  232. All of the above is pretty abstract. Here's what I suggest
  233. as a runner strategy for Social Engineering, given that neither
  234. software nor tables are available:
  235. (1) Figure out how much the run is worth. Call this
  236. number u. If u is less than 3 bits, don't play the
  237. Social.
  238. (2) Figure out how many bits the pool will have after
  239. playing the social. Call this number n.
  240. (3) If n is more bits that the runner can safely lose,
  241. reduce n to the number of bits the runner can safely lose.
  242. (4) If n is 4 or less and u < 5, don't play the Social.
  243. (5) If n is greater than 6:
  244. (5a) Obtain or synthesize an m-sided die,
  245. with n > m.
  246. (5b) Reroll until the result r of the roll
  247. satisfies 1 <= r <= n.
  248. (5c) If r is 1, make r be two.
  249. (5d) Risk r bits.
  250. (6) Otherwise:
  251. (6b) Obtain a 6-sided die.
  252. (6c) Reroll until the result r of the roll
  253. satisfies 2 <= r <= n.
  254. (6d) Risk r bits.
  255. When written out like this, the algorithm looks pretty complicated.
  256. In point of fact, it's pretty straightforward once you get the hang
  257. of it.
  258.  
  259. One last obvious question is: what of the poor Corp? Well,
  260. the Runner has been careful to make any strategy yield
  261. pretty similar results. The Corp must simply pick randomly
  262. among the available strategies, in order to prevent the Runner
  263. guessing what's going to happen. Here's the algorithm I suggest
  264. for the Corp.
  265. (1) Figure out how many bits the pool will have after
  266. playing the social. Call this number n.
  267. (2) Figure out how many bits the runner can safely lose.
  268. If this is less than n, set n to this value + 1.
  269. (3) If the runner is playing with a table or device,
  270. use a die to select randomly from the range 2..n.
  271. (4) If n > 6, roll an m-sided die, and count any 1 result
  272. as a n, until the result r is in range. Guess r.
  273. (5) If n <= 6, roll a 6-sided die, and count any 1 result
  274. as a 2, until the result r is in range. Guess r.
  275. This isn't perfect, but is good enough in my opinion. There's
  276. a little game the runner can play with n vs. n - 1 and a large
  277. bit pool, but it hardly matters in this case anyhow.
  278.  
  279. So, how good a card is Social Engineering, anyhow? Looks like
  280. it's a little better deal than Inside Job in most cases: the
  281. extra 0.5-1.5 bit expected penalty for choosing an arbitrary
  282. piece of ice is pretty tasty in a lot of situations. (On the
  283. other hand, since Inside Job passes the 1st ice it encounters,
  284. it can be useful in situations where the Corp can't afford to
  285. rez more than 1 of the several pieces of ice on a fort. Ce'st
  286. La Vie.) Hopefully, this exposition will help Runners and
  287. Corps alike deal with Social Engineering, and encourage its use.
  288.  
  289. Appendix A: Guess Tables For Social Engineering
  290.  
  291. To use these tables: Find the table for the u value you are
  292. interested in, and go to the column for the n of the bit pool
  293. you have and are willing to risk. The e value, at the bottom,
  294. tells how much, including opportunity cost, this Social run
  295. will cost you. If this is acceptable, then play the Social,
  296. and roll d100. Pick the row whose entry in your chosen column
  297. is the largest value less than or equal to the die roll. Look
  298. to the left to see how many bits to risk.
  299.  
  300. u=0
  301. b= n=03 n=04 n=05 n=06 n=07 n=08 n=09 n=10 n=11 n=12 n=13 n=14 n=15
  302. 02----59---45---37---33---30---28---26---24---23---22---21---21---20
  303. 03----99---75---63---56---51---47---44---42---40---38---37---36---34
  304. 04---------99---83---73---67---62---58---55---52---50---48---47---45
  305. 05--------------99---87---79---73---69---65---62---60---57---55---54
  306. 06-------------------99---90---83---78---74---70---67---65---63---61
  307. 07------------------------99---91---86---81---77---74---72---69---67
  308. 08-----------------------------99---92---88---84---80---77---75---73
  309. 09----------------------------------99---93---89---85---82---80---77
  310. 10---------------------------------------99---94---90---87---84---82
  311. 11--------------------------------------------99---95---91---88---86
  312. 12-------------------------------------------------99---95---92---89
  313. 13------------------------------------------------------99---95---93
  314. 14-----------------------------------------------------------99---96
  315. 15----------------------------------------------------------------99
  316. e= 2.20 1.92 1.78 1.69 1.63 1.58 1.55 1.52 1.50 1.48 1.46 1.44 1.43
  317.  
  318. u=1
  319. b= n=03 n=04 n=05 n=06 n=07 n=08 n=09 n=10 n=11 n=12 n=13 n=14 n=15
  320. 02----56---41---34---29---26---24---22---20---19---18---18---17---16
  321. 03----99---73---60---52---46---42---39---37---35---33---32---31---30
  322. 04---------99---81---70---63---57---53---50---47---45---43---42---40
  323. 05--------------99---85---77---70---65---61---58---55---53---51---49
  324. 06-------------------99---88---81---75---70---67---64---61---59---57
  325. 07------------------------99---90---84---79---74---71---68---65---63
  326. 08-----------------------------99---92---86---81---78---74---72---69
  327. 09----------------------------------99---93---88---84---80---77---74
  328. 10---------------------------------------99---93---89---85---82---79
  329. 11--------------------------------------------99---94---90---87---84
  330. 12-------------------------------------------------99---94---91---88
  331. 13------------------------------------------------------99---95---92
  332. 14-----------------------------------------------------------99---95
  333. 15----------------------------------------------------------------99
  334. e= 2.71 2.28 2.05 1.92 1.82 1.75 1.70 1.66 1.62 1.60 1.57 1.55 1.53
  335.  
  336. u=2
  337. b= n=03 n=04 n=05 n=06 n=07 n=08 n=09 n=10 n=11 n=12 n=13 n=14 n=15
  338. 02----54---39---31---27---24---21---20---18---17---16---15---15---14
  339. 03----99---71---58---49---44---40---36---34---32---30---29---28---27
  340. 04---------99---80---68---60---55---50---47---44---42---40---38---37
  341. 05--------------99---84---75---68---63---58---55---52---50---48---46
  342. 06-------------------99---87---79---73---68---64---61---58---56---54
  343. 07------------------------99---89---82---77---72---69---66---63---60
  344. 08-----------------------------99---91---85---80---76---72---69---67
  345. 09----------------------------------99---92---87---82---78---75---72
  346. 10---------------------------------------99---93---88---84---81---78
  347. 11--------------------------------------------99---93---89---86---82
  348. 12-------------------------------------------------99---94---90---87
  349. 13------------------------------------------------------99---94---91
  350. 14-----------------------------------------------------------99---95
  351. 15----------------------------------------------------------------99
  352. e= 3.22 2.62 2.32 2.13 2.00 1.91 1.84 1.79 1.74 1.71 1.67 1.65 1.62
  353.  
  354. u=3
  355. b= n=03 n=04 n=05 n=06 n=07 n=08 n=09 n=10 n=11 n=12 n=13 n=14 n=15
  356. 02----53---38---30---25---22---20---18---17---16---15---14---13---13
  357. 03----99---70---56---48---42---38---34---32---30---28---27---26---24
  358. 04---------99---79---67---59---53---48---45---42---40---38---36---35
  359. 05--------------99---84---74---66---61---56---53---50---47---45---43
  360. 06-------------------99---87---78---72---66---62---59---56---53---51
  361. 07------------------------99---89---81---76---71---67---64---61---58
  362. 08-----------------------------99---90---84---79---74---71---68---65
  363. 09----------------------------------99---91---86---81---77---74---71
  364. 10---------------------------------------99---92---87---83---79---76
  365. 11--------------------------------------------99---93---89---85---81
  366. 12-------------------------------------------------99---94---90---86
  367. 13------------------------------------------------------99---94---90
  368. 14-----------------------------------------------------------99---95
  369. 15----------------------------------------------------------------99
  370. e= 3.73 2.96 2.58 2.34 2.18 2.07 1.98 1.91 1.86 1.81 1.77 1.74 1.71
  371.  
  372. u=4
  373. b= n=03 n=04 n=05 n=06 n=07 n=08 n=09 n=10 n=11 n=12 n=13 n=14 n=15
  374. 02----52---37---29---24---21---19---17---16---15---14---13---12---12
  375. 03----99---70---55---46---41---36---33---30---28---27---25---24---23
  376. 04---------99---78---66---57---51---47---43---40---38---36---34---33
  377. 05--------------99---83---73---65---59---55---51---48---46---44---42
  378. 06-------------------99---86---77---70---65---61---57---54---52---50
  379. 07------------------------99---88---81---75---70---66---62---59---57
  380. 08-----------------------------99---90---83---78---73---69---66---63
  381. 09----------------------------------99---91---85---80---76---73---69
  382. 10---------------------------------------99---92---87---82---78---75
  383. 11--------------------------------------------99---93---88---84---80
  384. 12-------------------------------------------------99---93---89---85
  385. 13------------------------------------------------------99---94---90
  386. 14-----------------------------------------------------------99---94
  387. 15----------------------------------------------------------------99
  388. e= 4.23 3.30 2.83 2.55 2.36 2.22 2.12 2.03 1.97 1.91 1.86 1.83 1.79
  389.  
  390. u=5
  391. b= n=03 n=04 n=05 n=06 n=07 n=08 n=09 n=10 n=11 n=12 n=13 n=14 n=15
  392. 02----52---36---28---24---20---18---16---15---14---13---12---12---11
  393. 03----99---69---54---46---40---35---32---29---27---26---24---23---22
  394. 04---------99---78---65---57---50---46---42---39---37---35---33---32
  395. 05--------------99---83---72---64---58---54---50---47---44---42---40
  396. 06-------------------99---86---77---70---64---60---56---53---50---48
  397. 07------------------------99---88---80---74---69---65---61---58---55
  398. 08-----------------------------99---90---83---77---72---68---65---62
  399. 09----------------------------------99---91---85---80---75---72---68
  400. 10---------------------------------------99---92---86---82---78---74
  401. 11--------------------------------------------99---93---88---83---80
  402. 12-------------------------------------------------99---93---89---85
  403. 13------------------------------------------------------99---94---90
  404. 14-----------------------------------------------------------99---94
  405. 15----------------------------------------------------------------99
  406. e= 4.73 3.64 3.09 2.75 2.53 2.37 2.25 2.15 2.07 2.01 1.96 1.91 1.87
  407.  
  408. u=6
  409. b= n=03 n=04 n=05 n=06 n=07 n=08 n=09 n=10 n=11 n=12 n=13 n=14 n=15
  410. 02----51---36---28---23---20---17---16---14---13---12---12---11---10
  411. 03----99---69---54---45---39---34---31---28---26---25---23---22---21
  412. 04---------99---77---64---56---50---45---41---38---36---34---32---30
  413. 05--------------99---82---71---63---57---53---49---46---43---41---39
  414. 06-------------------99---85---76---69---63---59---55---52---49---47
  415. 07------------------------99---88---79---73---68---64---60---57---54
  416. 08-----------------------------99---89---82---76---72---67---64---61
  417. 09----------------------------------99---91---84---79---74---71---67
  418. 10---------------------------------------99---92---86---81---77---73
  419. 11--------------------------------------------99---92---87---83---79
  420. 12-------------------------------------------------99---93---88---84
  421. 13------------------------------------------------------99---94---89
  422. 14-----------------------------------------------------------99---94
  423. 15----------------------------------------------------------------99
  424. e= 5.24 3.98 3.34 2.96 2.70 2.52 2.38 2.27 2.18 2.11 2.05 1.00 1.95
  425.  
  426. u=7
  427. b= n=03 n=04 n=05 n=06 n=07 n=08 n=09 n=10 n=11 n=12 n=13 n=14 n=15
  428. 02----51---35---27---23---19---17---15---14---13---12---11---10---10
  429. 03----99---68---53---44---38---34---30---28---26---24---22---21---20
  430. 04---------99---77---64---55---49---44---40---37---35---33---31---30
  431. 05--------------99---82---71---63---57---52---48---45---42---40---38
  432. 06-------------------99---85---75---68---63---58---54---51---48---46
  433. 07------------------------99---87---79---72---67---63---59---56---53
  434. 08-----------------------------99---89---82---76---71---67---63---60
  435. 09----------------------------------99---90---84---78---74---70---67
  436. 10---------------------------------------99---91---85---81---76---73
  437. 11--------------------------------------------99---92---87---82---78
  438. 12-------------------------------------------------99---93---88---84
  439. 13------------------------------------------------------99---93---89
  440. 14-----------------------------------------------------------99---94
  441. 15----------------------------------------------------------------99
  442. e= 5.74 4.31 3.60 3.16 2.87 2.67 2.51 2.39 2.29 2.20 2.14 2.08 2.03
  443.  
  444. u=8
  445. b= n=03 n=04 n=05 n=06 n=07 n=08 n=09 n=10 n=11 n=12 n=13 n=14 n=15
  446. 02----51---35---27---22---19---17---15---14---12---12---11---10---10
  447. 03----99---68---53---44---38---33---30---27---25---23---22---21---20
  448. 04---------99---77---63---55---48---43---40---37---34---32---30---29
  449. 05--------------99---82---70---62---56---51---47---44---42---39---37
  450. 06-------------------99---85---75---68---62---57---53---50---48---45
  451. 07------------------------99---87---79---72---67---62---58---55---53
  452. 08-----------------------------99---89---81---75---70---66---63---59
  453. 09----------------------------------99---90---83---78---73---69---66
  454. 10---------------------------------------99---91---85---80---76---72
  455. 11--------------------------------------------99---92---87---82---78
  456. 12-------------------------------------------------99---93---88---83
  457. 13------------------------------------------------------99---93---89
  458. 14-----------------------------------------------------------99---94
  459. 15----------------------------------------------------------------99
  460. e= 6.24 4.65 3.85 3.37 3.04 2.81 2.64 2.50 2.39 2.30 2.22 2.16 2.10
  461.  
  462. u=9
  463. b= n=03 n=04 n=05 n=06 n=07 n=08 n=09 n=10 n=11 n=12 n=13 n=14 n=15
  464. 02----51---35---27---22---19---16---15---13---12---11---10---10---09
  465. 03----99---68---53---43---37---33---29---27---25---23---21---20---19
  466. 04---------99---76---63---54---48---43---39---36---34---31---30---28
  467. 05--------------99---81---70---62---55---51---47---44---41---39---37
  468. 06-------------------99---85---75---67---61---57---53---50---47---44
  469. 07------------------------99---87---78---72---66---62---58---55---52
  470. 08-----------------------------99---89---81---75---70---66---62---59
  471. 09----------------------------------99---90---83---78---73---69---65
  472. 10---------------------------------------99---91---85---80---75---72
  473. 11--------------------------------------------99---92---86---82---77
  474. 12-------------------------------------------------99---93---87---83
  475. 13------------------------------------------------------99---93---88
  476. 14-----------------------------------------------------------99---94
  477. 15----------------------------------------------------------------99
  478. e= 6.74 4.98 4.09 3.57 3.21 2.96 2.77 2.62 2.50 2.40 2.31 2.24 2.18
  479.  
  480. u=10
  481. b= n=03 n=04 n=05 n=06 n=07 n=08 n=09 n=10 n=11 n=12 n=13 n=14 n=15
  482. 02----51---34---26---22---18---16---14---13---12---11---10---10---09
  483. 03----99---68---52---43---37---32---29---26---24---22---21---20---19
  484. 04---------99---76---63---54---47---42---39---36---33---31---29---28
  485. 05--------------99---81---70---61---55---50---46---43---40---38---36
  486. 06-------------------99---84---74---67---61---56---52---49---46---44
  487. 07------------------------99---87---78---71---66---61---57---54---51
  488. 08-----------------------------99---89---81---74---69---65---61---58
  489. 09----------------------------------99---90---83---77---72---68---65
  490. 10---------------------------------------99---91---85---79---75---71
  491. 11--------------------------------------------99---92---86---81---77
  492. 12-------------------------------------------------99---92---87---83
  493. 13------------------------------------------------------99---93---88
  494. 14-----------------------------------------------------------99---93
  495. 15----------------------------------------------------------------99
  496. e= 7.24 5.32 4.35 3.77 3.38 3.10 2.89 2.73 2.60 2.49 2.40 2.32 2.26
  497.  
  498. Appendix B: Algorithms Used In This Article
  499.  
  500. Here are the algorithms I used in computing the numbers used in
  501. the article, including the tables of Appendix A. They are
  502. written for Keith Packard's "nick" interactive calculator, but
  503. should be fairly understandable without it.
  504.  
  505. function norm(n,u) {
  506. auto i;
  507. auto s = 0;
  508. for (i = 2; i <= n; i++)
  509. s += 1/(i+u);
  510. return s;
  511. }
  512.  
  513. function p(i,n,u) {
  514. return (1/(i+u)) / norm(n,u);
  515. }
  516.  
  517. function ex(n,u) {
  518. return 1 + 1/norm(n,u);
  519. }
  520.  
  521. function dd(i,n,u) {
  522. auto j;
  523. auto s = 0;
  524. for (j = 2; j <= i; j++)
  525. s += p(j,n,u);
  526. return s;
  527. }
  528.  
  529. function d(i,n,u) {
  530. return floor(dd(i,n,u) * 100) - 1;
  531. }
  532.  
  533. function er(i,n,u) {
  534. return (1 + i + u) * (1/(n-1) - p(i,n,u));
  535. }
  536.  
  537. function er2(i,n,u) {
  538. auto k = 1 + i + u;
  539. if (i == 2)
  540. return k * (2/n - p(i,n,u));
  541. else
  542. return k * (1/n - p(i,n,u));
  543. }
  544.  
  545. function normtest(n,u) {
  546. auto i;
  547. auto s = 0;
  548. for (i = 2; i <= n; i++)
  549. s += p(i,n,u);
  550. return s;
  551. }
  552.  
  553. function printtab(u,nn) {
  554. auto i, n;
  555. printf("u=%d\n", u);
  556. printf("b= ");
  557. for (n = 3; n <= nn; n++)
  558. printf(" n=%02d", n);
  559. printf("\n");
  560. for (i = 2; i <= nn; i++) {
  561. printf("%02d-", i);
  562. for (n = 3; n <= nn; n++)
  563. if (i <= n)
  564. printf("---%02d", d(i,n,u));
  565. else
  566. printf("-----");
  567. printf("\n");
  568. }
  569. printf("e= %4.2f", ex(3,u));
  570. for (n = 4; n <= nn; n++)
  571. printf(" %4.2f", ex(n,u));
  572. printf("\n");
  573. }
  574.  
  575. function printtabs(nu,nn) {
  576. auto i;
  577. printtab(0,nn);
  578. for (i = 1; i <= nu; i++) {
  579. printf("\n");
  580. printtab(i,nn);
  581. }
  582. }
  583.  
  584. /* printtabs(10,15) */
Advertisement
Add Comment
Please, Sign In to add comment