random_uniform
- Graph.random_uniform(shape, lower_bound, upper_bound, seed=None, *, name=None)
Create a sample of uniformly distributed random numbers.
- Parameters:
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.
- Returns:
A tensor containing a sample of uniformly distributed random numbers with shape
shape
.- Return type:
See also
calculate_stochastic_optimization()
Function to find the minimum of generic stochastic functions.
random_choices
Create random samples from the data that you provide.
random_normal
Create a sample of uniformly distributed random numbers.
Examples
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.