Computing frequency distribution

The Frequency class has methods to count the number of data instances in a bucket, to count unique number of data instances, and so on. The interface to Frequency is very simple, and in most cases, it requires very few lines of code to get the desired calculations done.

As value types, Strings, integers, longs, and chars are all supported.

Note

Natural ordering is the default ordering for cumulative frequencies, but this can be overridden by supplying a Comparator to the constructor.

How to do it...

  1. Create a method that takes a double array as argument. We will be computing the frequency distributions of the values of this array:
            public void getFreqStats(double[] values){ 
    
  2. Create an object of the Frequency class:
     Frequency ...

Get Java Data Science Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.