public LinearDistribution(final Range<N> domain, final double y1) { _domain = nonNull(domain); _y1 = Math.max(y1, 0.0); _x1 = domain.getMin().doubleValue(); _y2 = Math.max(y2(_x1, domain.getMax().doubleValue(), y1), 0.0); if (_y2 == 0) { _x2 = 2.0 / _y1 + _x1; } else { _x2 = domain.getMax().doubleValue(); } _cdf = new CDF<>(_x1, _y1, _x2, _y2); _pdf = new PDF<>(_x1, _y1, _x2, _y2); }
/** * Create a new uniform distribution with the given {@code domain}. * * @param domain the domain of the distribution. * @throws NullPointerException if the {@code domain} is {@code null}. */ public UniformDistribution(final Range<N> domain) { _domain = requireNonNull(domain, "Domain"); _min = _domain.getMin().doubleValue(); _max = _domain.getMax().doubleValue(); }