对于Elo评分系统模拟,我需要从基本sqrt(10)中的逻辑分布中提取样本。在NumPy文档上,我发现:https : //docs.scipy.org/doc/numpy-1.10.0/reference/generation/numpy.random.logistic.html这使用基数“ e”中的概率密度:exp((loc-x)/scale)/(scale*(1+exp((loc-x)/scale))**2)我需要在基本sqrt(10)中使用概率密度。你知道我该怎么做吗?
1 回答

皈依舞
TA贡献1851条经验 获得超3个赞
经过一番检查后,我相当确定这在数学上是正确的:
def logistic_sample(n, loc = 0, scale = 1, base = np.exp(1)): p = np.random.rand(n) return loc + scale * np.log(p / (1 - p)) / np.log(base)
scipy.stats.rv_continuous
如果您确实需要深入研究该分布,则另一种可能性是创建一个新类:
class logistic_base_gen(scipy.stats.rv_continuous): def _pdf(self, x, loc, scale, base): return base ** ((loc - x) / scale) / (s * (1 + base ** ((loc - x) / scale)) ** 2)logistic_base = logistic_base_gen(0)logistic_base.rvs(loc, scale, np.sqrt(10), size = n)
添加回答
举报
0/150
提交
取消