python - 如何在 Python 中从 Wishart 分布中采样

标签 python random probability-distribution

我需要用 Python 从 Wishart 分布中生成随机样本。有没有简单的方法可以做到这一点?

最佳答案

scipy 有一个 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)

输出:

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

wishart.rvs 是用于随机变量采样的 Wishart 函数。

关于python - 如何在 Python 中从 Wishart 分布中采样,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53345540/

相关文章:

python - 如何在 celery 任务中锁定变量?

python - 忽略 python 地址中的序号

java - Android:随机数决定玩家的回合

machine-learning - 短语 "a machine learning algorithm learn a probability distribution"是什么意思?这里究竟发生了什么

javascript - 超几何模拟,通过洗牌一次选择全部给出错误的结果

R:类型为 ="h"的 plot() 函数错误表示小数字(对于 "lwd"的较大值)

python - 围绕按位运算符语句的讨论

python - Numba jit : "Typing error" and "All templates rejected with/without literals" 问题

python - 你如何从 Python 中的列表中选择 "x"个唯一数字?

sql - SQL Server 中的随机选择