# uniform

Source: https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/random/uniform

```python
random.uniform(shape, lower_bound, upper_bound, seed=None, *, name=None)
```

Create a sample of uniformly distributed random numbers.

### Parameters
* **shape** (*tuple*) – The shape of the sampled random numbers.
* **lower_bound** (*float*) – The inclusive lower bound of the interval of the uniform distribution.
* **upper_bound** (*float*) – The exclusive upper bound of the interval of the uniform distribution.
* **seed** (*int* *or* *None* *,* *optional*) – A seed for the random number generator. Defaults to None,
  in which case a random value for the seed is used.
* **name** (*str* *or* *None* *,* *optional*) – The name of the node.
### Returns
A tensor containing a sample of uniformly distributed random numbers
with shape `shape`.
### Return type
[Tensor](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Tensor.md#boulderopal.graph.Tensor)

### SEE ALSO
[`Graph.random.choices`](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/random/choices.md#boulderopal.graph.random.choices)
: Create random samples from the data that you provide.

[`Graph.random.normal`](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/random/normal.md#boulderopal.graph.random.normal)
: Create a sample of normally distributed random numbers.

[`boulderopal.run_stochastic_optimization`](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/run_stochastic_optimization.md#boulderopal.run_stochastic_optimization)
: Function to find the minimum of generic stochastic functions.

## Examples

Create a random tensor by sampling uniformly from $[0,\, 1)$.

```pycon
>>> samples = graph.random.uniform(
...     shape=(3, 1), lower_bound=0, upper_bound=1, seed=0, name="samples"
... )
>>> result = bo.execute_graph(graph=graph, output_node_names="samples")
>>> result["output"]["samples"]["value"]
array([[0.8069013], [0.79011373], [0.38818516]])
```

See more examples in the [How to optimize controls robust to strong noise sources](https://docs.q-ctrl.com/boulder-opal/user-guides/how-to-optimize-controls-robust-to-strong-noise-sources) user guide.
