However, these often start to get handwavy after the initial results are proved.
The code below just weights an input distribution of \(n\) features (in this case Uniform(0,1)),
by a weight vector with distribution Uniform(-0.5*size, +0.5*size), and applies
an activation function to the result.
By running this process over a matrix of samples, one can effectively measure
the value of size required to equalise the input variance with the output variance.
And this approach should give good training stability - since each layer of the network
will have an ‘amplification factor’ of approximately 1.
Doing this in code (essentially by Monte Carlo), makes it easy fiddle with the various
input and weight distribution functions, as well as the activation function, without
having to make approximations for the sake of algebraic tractability.