ExtendedGenerator.wishart(df, scale, size=None, *, check_valid='warn', tol=None, rank=None, method='svd')

Draw samples from the Wishart and pseudo-Wishart distributions.

df{int, array_like[int]}

Degree-of-freedom values. In array-like must broadcast with all but the final two dimensions of shape.


Shape matrix of the distribution. It must be symmetric and positive-semidefinite for sampling. Must have shape (c1, c2, …, cj, N, N) where (c1, c2, …, cj) broadcasts with the degree of freedom shape (d1, d2, …, dk).

sizeint or sequence[int], optional

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 by N, the output shape is (m,n,k,N,N). If no shape is specified, a single (N by N) sample is returned.

check_valid{‘warn’, ‘raise’, ‘ignore’ }, optional

Behavior when the covariance matrix has rank less than rank.

tolfloat, optional

Tolerance when checking the rank of shape. shape is cast to double before the check. If None, then the tolerance is automatically determined as a function of N and the limit of floating point precision.

rankint, optional

The rank of shape when generating from the Singular Wishart distribution. If None, then rank is set of N so that the draws from the standard Wishart or pseudo-Wishart are generated.

method{‘svd’, ‘eigh’, ‘cholesky’, ‘factor’}, optional

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. 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. When rank is less than N, then the N largest eigenvalues and their associated eigenvalues are used when method is svd or eigh. When method is ‘cholesky, then the Cholesky of the upper rank by rank block is used. factor assumes that scale has been pre-factored so that no transformation is applied. When using factor, no check is performed on the rank.


The generated variates from the Wishart distribution.

See also


Generate variates with an identify scale.


Uses the method of Odell and Feiveson [1] when df >= dim. Otherwise variates are directly generated as the inner product of df by dim arrays of standard normal random variates.



Odell, P. L. , and A. H. Feiveson (1966) A numerical procedure to generate a sample covariance matrix. Jour. Amer. Stat. Assoc. 61, 199–203


Uhlig, H. (1994). “On Singular Wishart and Singular Multivariate Beta Distributions”. The Annals of Statistics. 22: 395–405


Dıaz-Garcıa, J. A., Jáimez, R. G., & Mardia, K. V. (1997). Wishart and Pseudo-Wishart distributions and some applications to shape theory. Journal of Multivariate Analysis, 63(1), 73-87.