Talk:Chest loot/Archive 1

Method?
Hello, I was wondering how the values on the page were calculated. I got somewhat different ones.

My method was as follows:
 * Note that each chest has a number of rounds to fill itself, random from x to y.
 * Note that each chest defines a pool of items, each with a weight, and possible stack sizes, random from m to n.
 * So for a given item,
 * the chance of that item being picked to be filled is governed by its relative weight among all the items in the pool.
 * the number in a given chest will range across a matrix from xm to yn: number of rounds multiplied by stack size.
 * simple case: rounds is in the range 1–3, stack sizes is in the range 1–4
 * there are (1+y-x)×(1+n-m) = 3×4 = 12 ways to form products in this example,
 * and keep in mind the sum from 1 to n = ( n^2 + n )/2,
 * and the sum of all products in the product matrix 1–y:1–n = ( n^2 + n )/2 * ( y^2 + y )/2 ,
 * so [( n^2 + n )/2 * ( y^2 + y )/2 ] / [ (1+y-x)×(1+n-m) ] represents the average number of items once rounds are complete.
 * more complicated (real life) case, iron ingots in a village chest: rounds is in the range x–y = 3–8, stack size is in the range m–n = 1–5
 * there are (1+y-x)×(1+n-m) = 6×5 = 30 ways to form products in this example,
 * the sum of products of all numbers x–y and m–n involves (I believe)
 * taking the entire sum of products across 1–y:1–n ,
 * subtracting out sections of the matrix 1–y:1–(m-1) and 1–(x-1):1–n ,
 * then adding back in 1–(x-1):1–(m-1) once, since that quantity was subtracted out twice...
 * giving you: { [ ( n^2 + n )/2 * ( y^2 + y )/2 ] - [ ( (m-1)^2 + (m-1) )/2 * ( y^2 + y )/2 ] - [ ( n^2 + n )/2 * ( (x-1)^2 + (x-1) )/2 ] + [ ( (m-1)^2 + (m-1) )/2 * ( (x-1)^2 + (x-1) )/2 ] } / [ (1+y-x)×(1+n-m) ] represents the average number of items once rounds are complete.
 * so, avg num items in rounds = { [ ( 25 + 5 )/2 * ( 64 + 8 )/2 ] - [ ( 0 + 0 )/2 * ( 64 + 8 )/2 ] - [ ( 25 + 5 )/2 * ( 4 + 2 )/2 ] + [ ( 0 + 0 )/2 * ( 4 + 2 )/2 ] } / 30
 * = { [ 15 * 36 ] - [ 0 ] - [ 15 * 3 ] + [ 0 ] } / 30
 * = { [ 540 ] - [ 0 ] - [ 45 ] + [ 0 ] } / 30
 * = 16.5
 * avg number of items per chest = item weight * avg num items in rounds
 * for iron ingots in a village chest, that item weight is 10, and the total item weight is 94,
 * so, avg number of iron ingots per village chest = 10/94 * 16.5 ≈ 1.755

And god bless you if you follow that. I only describe it so that maybe a person can qualitatively say whether I'm down the wrong path or not.

And you know, I wanted to know if there was an easier way, or what your way was,. – Sealbudsman (Aaron) t/c 06:33, 26 May 2015 (UTC)


 * , would you perhaps be able to comment? –Goandgoo ᐸ Talk Contribs 09:20, 27 May 2015 (UTC)
 * The data on pages like Dungeon and Stronghold was taken from the code of the game. I'm too tired right now to do the math myself to see whether the table on this page is correct or not or whether Sealbudsman is on the right track, or even to try to figure out whether it's actually useful to say you'll get an average of 0.652 bread per dungeon chest over the long term versus just stating the stacks per chest and the weights and quantities of the possible items. Anomie x (talk) 12:14, 27 May 2015 (UTC)
 * I personally find calculated values like 'chance to get at least one of this item' (from pages like Dungeon and Stronghold) and 'expected number of this item per chest' (from this page) to be more directly useful than the raw stack sizes and weights -- for example when considering which kind of chests I might look in for a certain item, which is something I might do during gameplay.
 * Anyway all I really want to know from Seahen is, how Seahen got those numbers. Ideally, I just think if those numbers are going to be there, and updated as the game changes, the method of calculating them ought to be spelled out somewhere like on this talk page.  And right now I would just like to audit the page, but am finding it difficult.  I could be totally trying to do it conceptually wrong, the long way, or anything.  Nobody's shortcoming but my own, I'm sure, but I am just hoping we could eventually put together a bit of documentation. – Sealbudsman (Aaron) SealbudsmanFace.png t/c 15:11, 27 May 2015 (UTC)
 * My method was to take the average number of stacks per chest as the middle of the range (except for the dungeon chest, since that's documented as filling 8 slots chosen with replacement and then deduplicated, for which I used a specific formula from here with n=27, k=8). Then I took the average number of items per stack as the middle of its range, and the probability of each specific item per stack (given in each structure's article). Then I multiplied all three numbers together:
 * Copies of item A per chest = copies of item A per stack of item A × stacks of item A per stack of anything (i.e. probability that a given stack is of item A) × stacks of anything per chest
 * (Note that enchanted books in a village library chest are unstacked after they're generated.) I believe Sealbudsman's error is assuming that 2 stacks of the same item are just as likely as 1 stack of that item; that would be the case if the probability and then the number of stacks were rolled separately for each item (which would result in some chests generating empty and others overspilling, because no items or too many items had happened to be chosen). Seahen (talk) 06:56, 10 June 2015 (UTC)


 * Great to hear from you. Thanks so much.  I think my biggest problem was a failure to recognize that if you're trying to come up with the average number of items when using two random variables, you just need to multiply both averages, as I think you are describing.  My method was pretty unusably convoluted, although your method gets the same numbers as I get.
 * For instance, iron ingots in a village chest, the chest fills from 3 to 8 stacks, and iron ingots come in stacks of 1 to 5, with a weight of 10/94. So that, given your method (as I understand it), is (1+5)/2 × 10/94 × (8+3)/2 = 3 × ~0.106 × 5.5 ~= 1.755
 * Whereas you have it on the table as 1.350. Am I misunderstanding you? – Sealbudsman (Aaron) SealbudsmanFace.png t/c 02:36, 11 June 2015 (UTC)