:orphan:
# PetscRandomSetInterval
Sets the interval over which the random numbers will be distributed.  By default, this interval is [0,1). 
## Synopsis
```
#include "petscsys.h" 
PetscErrorCode PetscRandomSetInterval(PetscRandom r, PetscScalar low, PetscScalar high)
```
Not Collective


## Input Parameters

- ***r  -*** the random number generator context
- ***low -*** The lower bound of the interval
- ***high -*** The upper bound of the interval





## Notes
for complex numbers either the real part or the imaginary part of high must be greater than its low part; or both of them can be greater.

If the real or imaginary part of low and high are the same then that value is always returned in the real or imaginary part.


## See Also
 `PetscRandomCreate()`, `PetscRandomGetInterval()`

## Level
intermediate

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/sys/classes/random/interface/random.c.html#PetscRandomSetInterval">src/sys/classes/random/interface/random.c</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/field/tutorials/ex1.c.html">src/dm/field/tutorials/ex1.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/tutorials/swarm_ex3.c.html">src/dm/tutorials/swarm_ex3.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex11.c.html">src/ksp/ksp/tutorials/ex11.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex11f.F90.html">src/ksp/ksp/tutorials/ex11f.F90</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex60.c.html">src/ksp/ksp/tutorials/ex60.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex70.c.html">src/ksp/ksp/tutorials/ex70.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/tutorials/ex12.c.html">src/snes/tutorials/ex12.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/sys/classes/random/tutorials/ex1.c.html">src/sys/classes/random/tutorials/ex1.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/unconstrained/tutorials/spectraladjointassimilation.c.html">src/tao/unconstrained/tutorials/spectraladjointassimilation.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ts/tutorials/ex42.c.html">src/ts/tutorials/ex42.c</A><BR>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/sys/classes/random/interface/random.c)


[Index of all Sys routines](index.md)  
[Table of Contents for all manual pages](/manualpages/index.md)  
[Index of all manual pages](/manualpages/singleindex.md)  
