We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
根据您的红包实现算法,自己测试了一下数据,产生200W个红包 每个红包的总金额都是200 分给10个人,按理说在每个人获得的金额在概率分布中应该是20元左右,但是测试出来的结果 有同一个共性,就是 倒数 后面几个人获取的平均值 总是距离平均值很远。从概率的角度想 不应该出现这个问题吧
The text was updated successfully, but these errors were encountered:
@1yus2yus3
请把你测试的这段代码贴下,我模拟试试。
Sorry, something went wrong.
public static void main(String[] args) {
Map<Integer,List<Integer>> map = new HashMap(); for (int i = 0; i < 2000000; i++) { //产生红包 RedPacket redPacket = new RedPacket(); List<Integer> redPackets = redPacket.splitRedPacket(20000, 10); //System.out.println(redPackets); for (int j = 0; j < redPackets.size(); j++) { if(map.get(j) == null) { map.put(j,new ArrayList<Integer>()); } map.get(j).add(redPackets.get(j)); } } //对map进行数据统计 Iterator<Map.Entry<Integer, List<Integer>>> entryIterator = map.entrySet().iterator(); while (entryIterator.hasNext()) { Map.Entry<Integer, List<Integer>> next = entryIterator.next(); List<Integer> values = next.getValue(); IntSummaryStatistics stats = values.stream().mapToInt((x)->x).summaryStatistics(); System.out.println("第" + (next.getKey() + 1) + "个人获取到 平均值=" + stats.getAverage()); } }
No branches or pull requests
根据您的红包实现算法,自己测试了一下数据,产生200W个红包 每个红包的总金额都是200 分给10个人,按理说在每个人获得的金额在概率分布中应该是20元左右,但是测试出来的结果 有同一个共性,就是 倒数 后面几个人获取的平均值 总是距离平均值很远。从概率的角度想 不应该出现这个问题吧
The text was updated successfully, but these errors were encountered: