2024-06-16 12:42:47 发布
网友
我在寻找Java的等价代码或python的基础理论np.随机选择(Numpy作为np)。我正在尝试用Java实现Q-learning。我有一个类似的实现,它使用Python的np.随机选择从概率分布中选择随机移动的方法。在
Python's code
输入列表:['pooh'、'rabbit'、'piuge'、'Christopher']和概率:[0.5,0.1,0.3]
我想从输入列表中选择一个给定每个输入元素的相关概率的值。在
使用apachecommons数学库的好主意,EnumeratedInteger发行版,http://commons.apache.org/proper/commons-math/javadocs/api-3.6/org/apache/commons/math3/distribution/EnumeratedIntegerDistribution.html
沿着这条线(在一些伪代码中)
values = new String[4]{'pooh', 'rabbit', 'piglet', 'Christopher'}; dist = new EnumeratedIntegerDistribution(new int[4]{0,1,2,3}, new double[4]{0.5, 0.1, 0.1, 0.3}); int idx = dist.sample(); return values[idx];
使用apachecommons数学库的好主意,EnumeratedInteger发行版,http://commons.apache.org/proper/commons-math/javadocs/api-3.6/org/apache/commons/math3/distribution/EnumeratedIntegerDistribution.html
沿着这条线(在一些伪代码中)
相关问题 更多 >
编程相关推荐