# Talk:Chest loot/MethodAttempt

• 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.51.755