- Graph.random_uniform(shape, lower_bound, upper_bound, seed=None, *, name=None)
Create a sample of uniformly distributed random numbers.
shape (tuple or list) – The shape of the sampled random numbers.
lower_bound (int or float) – The inclusive lower bound of the interval of the uniform distribution.
upper_bound (int or 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.
A tensor containing a sample of uniformly distributed random numbers with shape
- Return type:
Create a random tensor by sampling uniformly from \([0,\, 1)\).
>>> samples = graph.random_uniform( ... shape=(3, 1), lower_bound=0, upper_bound=1, seed=0, name="samples" ... ) >>> result = qctrl.functions.calculate_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 user guide.