Documentation API of the 'org.apache.commons.math3.random.EmpiricalDistribution' Java class

Class EmpiricalDistribution

  • All Implemented Interfaces:
    Serializable, RealDistribution

    public class EmpiricalDistributionextends AbstractRealDistribution

    Represents an empirical probability distribution -- a probability distribution derived from observed data without making any assumptions about the functional form of the population distribution that the data come from.

    An EmpiricalDistribution maintains data structures, called distribution digests, that describe empirical distributions and support the following operations:

    • loading the distribution from a file of observed data values
    • dividing the input data into "bin ranges" and reporting bin frequency counts (data for histogram)
    • reporting univariate statistics describing the full set of data values as well as the observations within each bin
    • generating random values from the distribution
    Applications can use EmpiricalDistribution to build grouped frequency histograms representing the input data or to generate random values "like" those in the input file -- i.e., the values generated will follow the distribution of the values in the file.

    The implementation uses what amounts to the Variable Kernel Method with Gaussian smoothing:

    Digesting the input file

    1. Pass the file once to compute min and max.
    2. Divide the range from min-max into binCount "bins."
    3. Pass the data file again, computing bin counts and univariate statistics (mean, std dev.) for each of the bins
    4. Divide the interval (0,1) into subintervals associated with the bins, with the length of a bin's subinterval proportional to its count.
    Generating random values from the distribution
    1. Generate a uniformly distributed value in (0,1)
    2. Select the subinterval to which the value belongs.
    3. Generate a random Gaussian value with mean = mean of the associated bin and std dev = std dev of associated bin.

    EmpiricalDistribution implements the RealDistribution interface as follows. Given x within the range of values in the dataset, let B be the bin containing x and let K be the within-bin kernel for B. Let P(B-) be the sum of the probabilities of the bins below B and let K(B) be the mass of B under K (i.e., the integral of the kernel density over B). Then set P(X < x) = P(B-) + P(B) * K(x) / K(B) where K(x) is the kernel distribution evaluated at x. This results in a cdf that matches the grouped frequency distribution at the bin endpoints and interpolates within bins using within-bin kernels.

    • The binCount is set by default to 1000. A good rule of thumb is to set the bin count to approximately the length of the input file divided by 10.
    • The input file must be a plain text file containing one valid numeric entry per line.

    See Also:
    Serialized Form

Warning: You cannot see the full API documentation of this class since the access to the DatMelt documentation for third-party Java classes is denied. Guests can only view jhplot Java API. To view the complete description of this class and its methods, please request the full DataMelt membership.

If you are already a full member, please login to the DataMelt member area before visiting this documentation.