IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
20.1 General functions


20.1 General functions

seed( x=0, y=0)
The seed function takes two integers and sets the two seeds of the random number generator to those values. If the default values of 0 are used for both x and y, then a seed is generated from the current time, providing a pseudo-random seed.

get_seed( )
This function returns the two seeds used by the current random-number generator. It is most often used to find out what seeds the seed function chose at the last iteration.

random( shape=[])
The random function takes a shape, and returns an array of Float numbers between 0.0 and 1.0. Neither 0.0 nor 1.0 is ever returned by this function. The array is filled from the generator following the canonical array organization.

If no argument is specified, the function returns a single floating point number, not an array.

Note: See discussion of the flat attribute in section 10.

uniform( minimum, maximum, shape=[])
The uniform function returns an array of the specified shape and containing Float random numbers strictly between minimum and maximum.

The minimum and maximum arguments can be arrays. If this is the case, and the output shape is specified, minimum and maximum are broadcasted if their dimensions are not equal to shape. If shape is not specified, the shape of the output is equal to the shape of minimum and maximum after broadcasting.

If no shape is specified, and minimum and maximum are scalars, a single value is returned.

randint( minimum, maximum, shape=[])
The randint function returns an array of the specified shape and containing random (standard) integers greater than or equal to minimum and strictly less than maximum.

The minimum and maximum arguments can be arrays. If this is the case, and the output shape is specified, minimum and maximum are broadcasted if their dimensions are not equal to shape. If shape is not specified, the shape of the output is equal to the shape of minimum and maximum after broadcasting.

If no shape is specified, and minimum and maximum are scalars, a single value is returned.

permutation( n)
The permutation function returns an array of the integers between 0 and n-1, in an array of shape (n,) with its elements randomly permuted.

Send comments to the NumArray community.