VecSetRandomGaussian#

Fills a vector with Gaussian random values of the given mean and standard deviation.

Synopsis#

#include "petscvec.h"   
PetscErrorCode VecSetRandomGaussian(Vec v, PetscRandom rng, PetscReal mean, PetscReal std_dev)

Collective

Input Parameters#

  • v - the vector to fill

  • rng - PETSc random number generator

  • mean - desired mean of the Gaussian samples

  • std_dev - desired standard deviation

Note#

For complex builds where PetscScalar is complex the imaginary part of all the vector entries is zero

Developer Note#

Uses the Box-Muller transform to generate normally distributed random numbers from uniform random numbers. Handles edge cases where uniform random values approach 0 or 1.

See Also#

Vectors and Parallel Data, PetscDA: Data Assimilation, PetscDA, PetscRandom, PetscRandomSetInterval(), VecSetRandom()

Level#

advanced

Location#

src/vec/vec/interface/vector.c

Examples#

src/ml/da/tutorials/ex4.c
src/ml/da/tutorials/ex3.c
src/ml/da/tutorials/ex2.c
src/ml/da/tutorials/ex1.c


Index of all Vec routines
Table of Contents for all manual pages
Index of all manual pages