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

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 (default=1e-13)
rtolfloat (default=None)

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

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

Returns:
numpy.ndarray

A random (m x n)-matrix

Raises:
ValueError

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

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

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

Parameters:
nint

Dimension of the square matrix.

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.

Returns:
numpy.ndarray

A (n x n)-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.