The scipy.stats
suite of statistical distributions ( scipy.stats.norm
, scipy.stats.uniform
, scipy.stats.t
etc) all produce univariate data series using their own .rvs()
function, and only one has a multivariate rendition: multivariate_normal
, which corresponds to numpy
's numpy.random.randn((N,K))
. In fact, virtually all of the statistical distributions found in numpy.random
can produce multivariate data.
How can I extend the univariate distribution functions found in scipy.stats
to multivariate number generation, given that it possesses some distributions not found in numpy.random
like johnsonsu
? Must I manually make a loop function myself that concatenates multiple univariates together? what should that look like
I think you just want to pass a size
parameter to rvs
. For example:
from scipy import stats
stats.norm.rvs(size=10)
will give you a vector filled with 10 standard normal variates.
note that multivariate means something specific in statistics, not just IID copies of the same (which is what size
does). eg the cov
parameter to multivariate_normal
specifies the covariance matrix of all variates within one draw.
as another example, multinomial
is similar, but the parameters of the distribution are obviously different.
stats.multinomial.rvs(n=5, p=[0.5, 0.5], size=10)
tells you how many heads & tails you get from throwing a coin 5 times, repeating this 10 times. ie the rows are separate draws, the columns are the values within a draw
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.