001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.commons.math4.legacy.distribution; 018 019import org.apache.commons.rng.UniformRandomProvider; 020 021/** 022 * Base interface for multivariate distributions on the reals. 023 * 024 * This is based largely on the {@code ContinuousDistribution} interface, 025 * but cumulative distribution functions are not required because they 026 * are often quite difficult to compute for multivariate distributions. 027 * 028 * @since 3.1 029 */ 030public interface MultivariateRealDistribution { 031 /** 032 * Returns the probability density function (PDF) of this distribution 033 * evaluated at the specified point {@code x}. In general, the PDF is the 034 * derivative of the cumulative distribution function. If the derivative 035 * does not exist at {@code x}, then an appropriate replacement should be 036 * returned, e.g. {@code Double.POSITIVE_INFINITY}, {@code Double.NaN}, or 037 * the limit inferior or limit superior of the difference quotient. 038 * 039 * @param x Point at which the PDF is evaluated. 040 * @return the value of the probability density function at point {@code x}. 041 */ 042 double density(double[] x); 043 044 /** 045 * Gets the number of random variables of the distribution. 046 * It is the size of the array returned by the {@link Sampler#sample() sample} 047 * method. 048 * 049 * @return the number of variables. 050 */ 051 int getDimension(); 052 053 /** 054 * Creates a sampler. 055 * 056 * @param rng Generator of uniformly distributed numbers. 057 * @return a sampler that produces random numbers according this 058 * distribution. 059 * 060 * @since 4.0 061 */ 062 Sampler createSampler(UniformRandomProvider rng); 063 064 /** 065 * Sampling functionality. 066 * 067 * @since 4.0 068 */ 069 interface Sampler { 070 /** 071 * Generates a random value vector sampled from this distribution. 072 * 073 * @return a random value vector. 074 */ 075 double[] sample(); 076 } 077}