dask 2021.10.0

ParametersReturnsBackRef
random_sample(self, size=None, chunks='auto', **kwargs)

This docstring was copied from numpy.random.mtrand.RandomState.random_sample.

Some inconsistencies with the Dask version may exist.

Results are from the "continuous uniform" distribution over the stated interval. To sample $Unif[a, b), b > a$ multiply the output of random_sample by :None:None:`(b-a)` and add :None:None:`a`:

(b - a) * random_sample() + a
note

New code should use the random method of a default_rng() instance instead; please see the :None:ref:`random-quick-start`.

Parameters

size : int or tuple of ints, optional

Output shape. If the given shape is, e.g., (m, n, k) , then m * n * k samples are drawn. Default is None, in which case a single value is returned.

Returns

out : float or ndarray of floats

Array of random floats of shape :None:None:`size` (unless size=None , in which case a single float is returned).

Return random floats in the half-open interval [0.0, 1.0).

See Also

Generator.random

which should be used for new code.

Examples

This example is valid syntax, but we were not able to check execution
>>> np.random.random_sample()  # doctest: +SKIP
0.47108547995356098 # random
This example is valid syntax, but we were not able to check execution
>>> type(np.random.random_sample())  # doctest: +SKIP
<class 'float'>
This example is valid syntax, but we were not able to check execution
>>> np.random.random_sample((5,))  # doctest: +SKIP
array([ 0.30220482,  0.86820401,  0.1654503 ,  0.11659149,  0.54323428]) # random

Three-by-two array of random numbers from [-5, 0):

This example is valid syntax, but we were not able to check execution
>>> 5 * np.random.random_sample((3, 2)) - 5  # doctest: +SKIP
array([[-3.99149989, -0.52338984], # random
       [-2.99091858, -0.79479508],
       [-1.23204345, -1.75224494]])
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

dask.array.core.map_blocks dask.array.random.RandomState.uniform dask.array.random.RandomState.random_sample

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /dask/array/random.py#389
type: <class 'function'>
Commit: