Numerical methods for the discretization of random fields by means of the Karhunen–Loève expansion