与Matlab的"randsample"等效随机抽样 [英] Equivalent of Matlab's "randsample" random sample

查看:150
本文介绍了与Matlab的"randsample"等效随机抽样的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Java中是否有类似Matlab中的randsample的函数,该函数可以返回加权样本(随机替换均匀采样,并且每个数字的权重为w[i].选择数字i的概率为w(i)/sum(w).)

Is there a function in Java like the randsample in Matlab which can return weighted samples(sampled uniformly at random with replacement, and having a weight- w[i] for each number. The probability that a number i is selected is w(i)/sum(w).)?

我想使用这样的东西

    randsample([0 1],1,true,[0.2 0.8]);

推荐答案

您可以查看 Apache Commons Math 库.具体来说,您似乎对二项分布感兴趣.

You can look into the Apache Commons Math library. Specifically, it looks like you're interested in the Binomial Distribution.

希望有帮助!

这篇关于与Matlab的"randsample"等效随机抽样的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆