`set` is a built-in. He probably didn't want to smash it.
Defining a function and immediately calling it prevents pollution of module scope. Without it, `photo` would be exported.
The tests are in the same file because it makes the example self-contained, I assume.
The experiments are run 100,000 times because they have a random component and this exercises the system.