# rand

Uniformly distributed random numbers

## Syntax

## Description

`X = rand`

returns a random scalar drawn from the uniform
distribution in the interval (0,1).

`X = rand(`

returns
an `sz1,...,szN`

)`sz1`

-by-...-by-`szN`

array of
random numbers where `sz1,...,szN`

indicate the size
of each dimension. For example, `rand(3,4)`

returns
a 3-by-4 matrix.

`X = rand(___,`

returns an
array of random numbers of data type `typename`

)`typename`

. The
`typename`

input can be either `"single"`

or
`"double"`

. You can use any of the input arguments in the previous
syntaxes.

`X = rand(`

generates
numbers from random number stream `s`

,___)`s`

instead of the default global
stream. To create a stream, use `RandStream`

. You can specify `s`

followed by any
of the input argument combinations in previous syntaxes.

## Examples

## Input Arguments

## Tips

The sequence of numbers produced by

`rand`

is determined by the internal settings of the uniform pseudorandom number generator that underlies`rand`

,`randi`

, and`randn`

. You can control that shared random number generator using`rng`

.

## Extended Capabilities

## Version History

**Introduced before R2006a**

## See Also

`randi`

| `randn`

| `rng`

| `RandStream`

| `sprand`

| `sprandn`

| `randperm`

### Topics

- Create Arrays of Random Numbers
- Generate Random Numbers That Are Repeatable
- Generate Random Numbers That Are Different
- Random Numbers Within a Specific Range
- Random Numbers Within a Sphere
- Creating and Controlling a Random Number Stream
- Class Support for Array-Creation Functions
- Replace Discouraged Syntaxes of rand and randn
- Why Do Random Numbers Repeat After Startup?