# Random

How to sample numbers uniformly between 0 and 1.

#### New to Plotly?¶

Plotly's Python library is free and open source! Get started by downloading the client and reading the primer.

You can set up Plotly to work in online or offline mode, or in jupyter notebooks.

We also have a quick-reference cheatsheet (new!) to help you get started!

```
import plotly.plotly as py
import plotly.graph_objs as go
import numpy as np
```

#### Random and Rand¶

`np.random.random()`

and `np.random.rand()`

are identical functions used to return numbers sampled uniformly from the half-open interval $[0, 1)$. `np.random.rand()`

is just a `convenience function`

which is an instance of a subclass of the class `gdb.Function`

. By default the argument parameter `size`

is set to `None`

which means that a single random number is returned. `size`

can be entered as a shape, which is just a tuple of integers representing the dimentions of the array to be outputted.

```
import plotly.plotly as py
import plotly.graph_objs as go
num_of_points = 20
random_array = np.random.random((num_of_points))
trace1 = go.Scatter(
x=[j for j in range(len(random_array))],
y=random_array,
mode='markers',
marker = dict(
size=15,
color=random_array,
colorscale='Viridis'
),
name='random array'
)
py.iplot([trace1], filename='numpy-random')
```

```
help(np.random.random)
```