# Expected Occupied Volume of Cubic Region with Intersecting Cubic Objects

I have a simulation in which I generate $n$ small cubes with side length $w$, with random (uniformly distributed) positions inside a large cubic region with side length $S$.

The smaller cubes are allowed to intersect, but are constrained to be wholly inside the large region.

I need to determine an estimate (expected value) of the total volume occupied by the smaller cubes, taking their possible intersection into account.

I suspect the problem at Expected occupied area of a surface covered with possibly overlapping random shapes. is related, but I do not understand how the answerer gets from the second last to the last step. I get a different result. I would greatly appreciate any help.