How to sample from a Wishart Distribution in Python

Viewed 1704

I need to generate random samples from a Wishart Distribution in Python. Is there a simple way to do that?

1 Answers

scipy has a package for wishart:

import numpy as np
from scipy.stats import wishart

x = np.linspace(1e-5, 8, 100) # make an array
for y in x:
    z = wishart.rvs(1, scale=y)
    print(z)

output:

4.59465858669e-06
0.00403122342709
0.0268879506122
0.0100029090879
0.129477863995
0.372787021348
....

wishart.rvs is the wishart function for random variate sampling.

Related