我如何计算 C# 中 List<double> 上数字的频率?
How would i count the frequency of a number on an List<double> in C#?
我有一个 <code>IList<double>
,我正在尝试查找列表中出现频率最高的值,以及列表中每个数字出现的频率列表,但它如何以我得到每个值的 IDictionary<number, frequency>
之类的方式工作?
谢谢:)
var dictionary= list.GroupBy(x => x).ToDictionary(x => x.Key, x => x.Count());
我有一个 <code>IList<double>
,我正在尝试查找列表中出现频率最高的值,以及列表中每个数字出现的频率列表,但它如何以我得到每个值的 IDictionary<number, frequency>
之类的方式工作?
谢谢:)
var dictionary= list.GroupBy(x => x).ToDictionary(x => x.Key, x => x.Count());