Example usage for org.apache.commons.math.distribution AbstractContinuousDistribution density

List of usage examples for org.apache.commons.math.distribution AbstractContinuousDistribution density

Introduction

In this page you can find the example usage for org.apache.commons.math.distribution AbstractContinuousDistribution density.

Prototype

public double density(double x) throws MathRuntimeException 

Source Link

Document

Return the probability density for a particular point.

Usage

From source file:org.renjin.Distributions.java

/**
 * Calculates the value of the density function at {@code x}
 * for the given continuous distribution
 *
 * @param dist the distribution of the random variable
 * @param x the value/*  w  w  w.ja va2  s . c  om*/
 * @param log whether to return the natural logarithm of the function's value
 * @return the (natural logarithm) of the relative likelihood for the random
 * variable to take the value {@code x}
 */
private static double d(AbstractContinuousDistribution dist, double x, boolean log) {
    double d = dist.density(x);
    if (log) {
        d = Math.log(d);
    }
    return d;
}