randomgen.generator.ExtendedGenerator.multivariate_complex_normal¶
-
ExtendedGenerator.multivariate_complex_normal(loc, gamma=
None
, relation=None
, size=None
, *, check_valid='warn'
, tol=1e-8
, method='svd'
)¶ Draw random samples from a multivariate complex normal (Gaussian) distribution.
- Parameters:¶
- loc¶
Mean of the distribution. Must have shape (m1, m2, …, mk, N) where (m1, m2, …, mk) would broadcast with (g1, g2, …, gj) and (r1, r2, …, rq).
- gamma=
None
¶ Covariance of the real component of the distribution. Must have shape (g1, g2, …, gj, N, N) where (g1, g2, …, gj) would broadcast with (m1, m2, …, mk) and (r1, r2, …, rq). If not provided, an identity matrix is used which produces the circularly-symmetric complex normal when relation is an array of 0.
- relation=
None
¶ Relation between the two component normals. (r1, r2, …, rq, N, N) where (r1, r2, …, rq, N, N) would broadcast with (m1, m2, …, mk) and (g1, g2, …, gj). If not provided, set to zero which produces the circularly-symmetric complex normal when gamma is an identify matrix.
- size=
None
¶ Given a shape of, for example,
(m,n,k)
,m*n*k
samples are generated, and packed in an m-by-n-by-k arrangement. Because each sample is N-dimensional, the output shape is(m,n,k,N)
. If no shape is specified, a single (N-D) sample is returned.- check_valid=
'warn'
¶ Behavior when the covariance matrix implied by gamma and relation is not positive semidefinite.
- tol=
1e-8
¶ Tolerance when checking the singular values in the covariance matrix implied by gamma and relation.
- method=
'svd'
¶ The cov input is used to compute a factor matrix A such that
A @ A.T = cov
. This argument is used to select the method used to compute the factor matrix A for the covariance implied by gamma and relation. The default method ‘svd’ is the slowest, while ‘cholesky’ is the fastest but less robust than the slowest method. The method eigh uses eigen decomposition to compute A and is faster than svd but slower than cholesky.
- Returns:¶
out – Drawn samples from the parameterized complex normal distributions.
- Return type:¶
See also
numpy.random.Generator.normal
random values from a real-valued normal distribution
randomgen.generator.ExtendedGenerator.complex_normal
random values from a scalar complex-valued normal distribution
randomgen.generator.ExtendedGenerator.multivariate_normal
random values from a scalar complex-valued normal distribution
Notes
Complex normals are generated from a multivariate normal where the covariance matrix of the real and imaginary components is
\[\begin{split}\begin{array}{c} X\\ Y \end{array}\sim N\left(\left[\begin{array}{c} \mathrm{Re\left[\mu\right]}\\ \mathrm{Im\left[\mu\right]} \end{array}\right],\frac{1}{2}\left[\begin{array}{cc} \mathrm{Re}\left[\Gamma+C\right] & \mathrm{Im}\left[C-\Gamma\right]\\ \mathrm{Im}\left[\Gamma+C\right] & \mathrm{Re}\left[\Gamma-C\right] \end{array}\right]\right)\end{split}\]The complex normals are then
\[Z = X + iY\]If the implied covariance matrix is not positive semi-definite a warning or exception may be raised depending on the value check_valid.
The implementation is based in the mathematical description in [1] and [2].
References
Examples
Draw samples from the standard multivariate complex normal
>>> from randomgen import ExtendedGenerator >>> eg = ExtendedGenerator() >>> loc = np.zeros(3) >>> eg.multivariate_complex_normal(loc, size=2) array([[ 0.42551611+0.44163456j, -0.18366146+0.88380663j, -0.3035725 -1.19754723j], [-0.86649667-0.88447445j, -0.04913229-0.04674949j, -0.28145563+1.04682163j]])
Draw samples a trivariate centered circularly symmetric complex normal
>>> rho = 0.7 >>> gamma = rho * np.eye(3) + (1-rho) * np.diag(np.ones(3)) >>> eg.multivariate_complex_normal(loc, gamma, size=3) array([[ 0.32699266-0.57787275j, 0.46716898-0.06687298j, -0.31483301+0.17233599j], [ 0.28036548-0.56994348j, 0.18011468-0.50539209j, 0.35185607-0.15184288j], [-0.1866397 +1.2701576j , -0.18419364-0.06912343j, -0.66462037+0.73939778j]])
Draw samples from a bivariate distribution with correlation between the real and imaginary components
>>> loc = np.array([3-7j, 2+4j]) >>> gamma = np.array([[2, 0 + 1.0j], [-0 - 1.0j, 2]]) >>> rel = np.array([[-1.8, 0 + 0.1j], [0 + 0.1j, -1.8]]) >>> eg.multivariate_complex_normal(loc, gamma, size=3) array([[2.97279918-5.64185732j, 2.32361134+3.23587346j], [1.91476019-7.91802901j, 1.76788821+3.84832672j], [4.44740101-7.93782402j, 1.59809459+1.35360097j]])