using the mean, this is what it would be from first principles

interestingly, it doesn't work. So what it is about dividing by w that
helps, regularisation