ddg.math.random module

ddg.math.random.random_matrix(m, n, rank=None, seed=None, atol=1e-13, rtol=None)[source]

Returns a random (m x n)-matrix of a specific rank.

Parameters:
mint

Number of rows of matrix

nint

Number of columns of matrix

rankint, optional.

Rank of matrix. If None, a full rank matrix is returned

seedint, numpy.random.Generator or None (default=None)

Passes a fixed seed to default Generator class. If passed a Generator, just uses that generator for random generation.

atolfloat

The absolute tolerance used in the computation of rank of the matrix.

rtolfloat

The relative tolerance used in the computation of rank of the matrix.

Returns:
numpy.ndarray

A random (m x n)-matrix

Raises:
ValueError

If rank of matrix is strictly greater than min(m, n)

Notes

This function uses the global tolerance defaults if atol or rtol are set to None. See ddg.abc.NonExact for details.

ddg.math.random.random_matrix_close_to_identity(n, seed=None)[source]

Returns a random (n x n)-matrix close to identity matrix.

ddg.math.random.random_point_on_sphere(n, seed=None)[source]

Draws a point on the n-dimensional unit sphere with uniform distribution.

Parameters:
nint

Dimension of the unit sphere.

seedfloat, optional.

Passes a fixed seed to default Generator class.

Returns:
numpy.array of shape (n+1,)

Point on the n-dimensional unit sphere.