Random function based spectral representation of stationary and non-stationary stochastic processes