The problems of statistical modeling of the optical radiation transfer through stochastic scattering and absorbing media are considered. It is assumed that the spatial variations of optical parameters of these media are random. The weighting algorithm proposed in the paper enables one to optimize modeling. In this approach, random trajectories are constructed for a determined medium, while random variations of its optical parameters are considered by calculating special weighting factors. In a great number of practically important problems in optics of stochastic media, the algorithm allows a simple numerical or sometimes analytical integration of the corresponding random estimates, which are necessary in calculating average characteristics of the radiation field. The algorithm developed allows one to construct numerical models of the electromagnetic radiation in randomly inhomogeneous media mostly intended for solving problems of solar radiation transfer through the stochastic continuous cloudiness.