Example usage for org.apache.commons.math3.distribution IntegerDistribution toString

List of usage examples for org.apache.commons.math3.distribution IntegerDistribution toString

Introduction

In this page you can find the example usage for org.apache.commons.math3.distribution IntegerDistribution toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:com.wormsim.utils.Utils.java

/**
 * Returns a string representation of the provided distribution. TODO: Make
 * this complete TODO: Make this compatible with custom distributions (or just
 * more complex ones)./*from   w ww .  ja v a 2 s . c o  m*/
 *
 * @param dist The distribution to translate
 *
 * @return The distribution as a string.
 */
public static String integerDistributionToString(IntegerDistribution dist) {
    if (dist instanceof EnumeratedIntegerDistribution) {
        return Double.toString(dist.getNumericalMean());
    } else if (dist instanceof UniformIntegerDistribution) {
        return "Uniform(" + dist.getSupportLowerBound() + "," + dist.getSupportUpperBound() + ")";
    } else if (dist instanceof BinomialDistribution) {
        BinomialDistribution dist2 = (BinomialDistribution) dist;
        return "Binomial(" + dist2.getNumberOfTrials() + "," + dist2.getProbabilityOfSuccess() + ")";
    } else {
        return dist.toString();
    }
}