Java中的相对频率 [英] Relative frequency in java

查看:82
本文介绍了Java中的相对频率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个程序来帮助我进行统计,但是从一开始我就遇到了问题,并且我正陷入混乱,无法计算只有一个维度的随机数数组的相对频率.

I want to create a program to help me with the statistics, but I'm having problems from the beginning and I'm making a huge mess to calculate the relative frequency of an array with random numbers and only one dimension.

例如,生成这些数字:

{3,5,5,2,4,1,3,5,4}

{3, 5, 5, 2, 4, 1, 3, 5, 4}

我希望程序告诉我3重复2次,4 3次,5 5次

I want that the program tell me that the 3 is repeated 2 times, the 4 3 times and 5 5 times

我创建了一个类来对这些值进行排序以计算中位数,第一和第三四分位数,但我仍然不知道如何找到频率以计算其他值

I've created a class to sort these values ​​in order to calculate the median, the first and third quartile, but I still do not know how to find the frequency in order to calculate other values

感谢您的时间

PS:不知道这是否会影响任何东西,但我使用的是 netbeans

PS: Do not know if this affects anything but I'm using netbeans

推荐答案

您正在确定是否要寻找它:

You are looking for this for sure: Collections: frequency

如果没有集合,请先将数组转换为列表:

If you dont have a Collection, convert your array to list first:

Collections.frequency(Arrays.asList(yourArray), new Integer(3))

这篇关于Java中的相对频率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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